Class: Account::TwoFactorsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Account::TwoFactorsController
- Defined in:
- app/controllers/account/two_factors_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
20 21 22 23 24 25 |
# File 'app/controllers/account/two_factors_controller.rb', line 20 def create @backup_codes = current_user.generate_otp_backup_codes! @user = current_user current_user.update(otp_secret: User.generate_otp_secret) end |
#destroy ⇒ Object
27 28 29 30 31 32 33 |
# File 'app/controllers/account/two_factors_controller.rb', line 27 def destroy @user = current_user current_user.update( otp_required_for_login: false, otp_secret: nil ) end |
#verify ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/controllers/account/two_factors_controller.rb', line 4 def verify @user = current_user otp_code = params["user"]["otp_attempt"] @verified = current_user.validate_and_consume_otp!(otp_code) if @verified current_user.update(otp_required_for_login: true) else current_user.update( otp_required_for_login: false, otp_secret: nil ) end end |