diff options
author | Robert Speicher <rspeicher@gmail.com> | 2015-06-22 21:13:49 -0400 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2015-06-22 21:14:07 -0400 |
commit | dcfce8b1988af62806a8bcdfd38bc2dcc0b7cf4e (patch) | |
tree | d3d559bcecf001326ca86a4838ef1bf1d1803db6 /app/models/user.rb | |
parent | aedb546964cc6b6e456369bf17a3d917089f7017 (diff) | |
download | gitlab-ce-rs-dev-issue-2414.tar.gz |
Use alias_attribute to define User#two_factor_enabledrs-dev-issue-2414
Diffstat (limited to 'app/models/user.rb')
-rw-r--r-- | app/models/user.rb | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 9f1bdb12508..15782bcf9c1 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -80,6 +80,7 @@ class User < ActiveRecord::Base devise :two_factor_authenticatable, otp_secret_encryption_key: File.read(Rails.root.join('.secret')).chomp + alias_attribute :two_factor_enabled, :otp_required_for_login devise :two_factor_backupable, otp_number_of_backup_codes: 10 serialize :otp_backup_codes, JSON @@ -198,8 +199,8 @@ class User < ActiveRecord::Base scope :active, -> { with_state(:active) } scope :not_in_project, ->(project) { project.users.present? ? where("id not in (:ids)", ids: project.users.map(&:id) ) : all } scope :without_projects, -> { where('id NOT IN (SELECT DISTINCT(user_id) FROM members)') } - scope :with_two_factor, -> { where(otp_required_for_login: true) } - scope :without_two_factor, -> { where(otp_required_for_login: false) } + scope :with_two_factor, -> { where(two_factor_enabled: true) } + scope :without_two_factor, -> { where(two_factor_enabled: false) } # # Class methods @@ -309,18 +310,6 @@ class User < ActiveRecord::Base @reset_token end - # Check if the user has enabled Two-factor Authentication - def two_factor_enabled? - otp_required_for_login - end - - # Set whether or not Two-factor Authentication is enabled for the current user - # - # setting - Boolean - def two_factor_enabled=(setting) - self.otp_required_for_login = setting - end - def namespace_uniq namespace_name = self.username existing_namespace = Namespace.by_path(namespace_name) |