Skip to content

Commit

Permalink
Ensure 1 IT1 application per user.
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharydenton authored and aptos-bot committed May 7, 2022
1 parent 78658f5 commit 884f5a2
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ def set_csrf_cookie
end

def after_sign_in_path_for(user)
stored_location_for(user) ||
if user.email.nil?
onboarding_email_path
else
overview_index_path
end
if user.email.nil?
onboarding_email_path
else
stored_location_for(user) || overview_index_path
end
end

def admin_access_denied(_exception)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class It1ProfilesController < ApplicationController

# GET /it1_profiles/new
def new
redirect_to overview_index_path if current_user.it1_profile.present?
@it1_profile = It1Profile.new
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# frozen_string_literal: true

class WelcomeController < ApplicationController
def index; end
def index
redirect_to overview_index_path if user_signed_in?
end

def it1; end
end
1 change: 1 addition & 0 deletions ecosystem/platform/server/app/models/it1_profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

class It1Profile < ApplicationRecord
belongs_to :user
validates :user_id, uniqueness: true

validates :consensus_key, presence: true, uniqueness: true, format: { with: /\A0x[a-f0-9]{64}\z/i }
validates :account_key, presence: true, uniqueness: true, format: { with: /\A0x[a-f0-9]{64}\z/i }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
class CreateIt1Profiles < ActiveRecord::Migration[7.0]
def change
create_table :it1_profiles do |t|
t.references :user, null: false, foreign_key: true
t.string :consensus_key
t.string :account_key
t.string :network_key
t.references :user, null: false, foreign_key: true, unique: true
t.string :consensus_key, unique: true
t.string :account_key, unique: true
t.string :network_key, unique: true
t.string :validator_address
t.integer :validator_port
t.integer :metrics_port
Expand Down

0 comments on commit 884f5a2

Please sign in to comment.