This repository has been archived on 2024-07-31. You can view files and clone it, but cannot push or open issues or pull requests.
2017-04-21 22:23:17 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Settings
|
|
|
|
module TwoFactorAuthentication
|
2018-12-12 16:32:13 -05:00
|
|
|
class RecoveryCodesController < BaseController
|
2019-09-18 10:37:27 -04:00
|
|
|
include ChallengableConcern
|
|
|
|
|
2020-09-11 14:56:35 -04:00
|
|
|
skip_before_action :require_functional!
|
2017-04-21 22:23:17 -04:00
|
|
|
|
2019-09-18 10:37:27 -04:00
|
|
|
before_action :require_challenge!, on: :create
|
2017-04-21 22:23:17 -04:00
|
|
|
|
|
|
|
def create
|
|
|
|
@recovery_codes = current_user.generate_otp_backup_codes!
|
|
|
|
current_user.save!
|
2019-09-18 10:37:27 -04:00
|
|
|
|
|
|
|
UserMailer.two_factor_recovery_codes_changed(current_user).deliver_later!
|
2019-07-19 17:13:21 -04:00
|
|
|
flash.now[:notice] = I18n.t('two_factor_authentication.recovery_codes_regenerated')
|
2019-09-18 10:37:27 -04:00
|
|
|
|
2017-04-21 22:23:17 -04:00
|
|
|
render :index
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|