diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-07-13 08:47:55 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-07-13 08:47:55 +0000 |
commit | d93da8bed598249c67b71b3acdd4944952e80db2 (patch) | |
tree | 598b507e1be2a5c6aba787867477f6fe0235cf7a /app | |
parent | 10d5da784b130f6227dd8074dfc51f9627293031 (diff) | |
parent | 22724418d350001e2683b68fad65186af783d3f2 (diff) | |
download | gitlab-ce-d93da8bed598249c67b71b3acdd4944952e80db2.tar.gz |
Merge branch 'rs-disable-2fa' into 'master'
Add User#disable_two_factor!
This method encapsulates all the logic for disabling 2FA on a specific
User model.
See merge request !961
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/profiles/two_factor_auths_controller.rb | 8 | ||||
-rw-r--r-- | app/models/user.rb | 10 |
2 files changed, 11 insertions, 7 deletions
diff --git a/app/controllers/profiles/two_factor_auths_controller.rb b/app/controllers/profiles/two_factor_auths_controller.rb index 03845f1e1ec..f9af0871cf1 100644 --- a/app/controllers/profiles/two_factor_auths_controller.rb +++ b/app/controllers/profiles/two_factor_auths_controller.rb @@ -29,13 +29,7 @@ class Profiles::TwoFactorAuthsController < Profiles::ApplicationController end def destroy - current_user.update_attributes({ - two_factor_enabled: false, - encrypted_otp_secret: nil, - encrypted_otp_secret_iv: nil, - encrypted_otp_secret_salt: nil, - otp_backup_codes: nil - }) + current_user.disable_two_factor! redirect_to profile_account_path end diff --git a/app/models/user.rb b/app/models/user.rb index dc84f5141d8..317257a2500 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -322,6 +322,16 @@ class User < ActiveRecord::Base @reset_token end + def disable_two_factor! + update_attributes( + two_factor_enabled: false, + encrypted_otp_secret: nil, + encrypted_otp_secret_iv: nil, + encrypted_otp_secret_salt: nil, + otp_backup_codes: nil + ) + end + def namespace_uniq namespace_name = self.username existing_namespace = Namespace.by_path(namespace_name) |