recovery_codes_controller.rb 665 B

1234567891011121314151617181920212223242526
  1. # frozen_string_literal: true
  2. module Settings
  3. module TwoFactorAuthentication
  4. class RecoveryCodesController < BaseController
  5. include ChallengableConcern
  6. layout 'admin'
  7. before_action :authenticate_user!
  8. before_action :require_challenge!, on: :create
  9. skip_before_action :require_functional!
  10. def create
  11. @recovery_codes = current_user.generate_otp_backup_codes!
  12. current_user.save!
  13. UserMailer.two_factor_recovery_codes_changed(current_user).deliver_later!
  14. flash.now[:notice] = I18n.t('two_factor_authentication.recovery_codes_regenerated')
  15. render :index
  16. end
  17. end
  18. end
  19. end