2017-04-22 12:23:17 +10:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Settings
|
|
|
|
module TwoFactorAuthentication
|
2018-12-13 08:32:13 +11:00
|
|
|
class RecoveryCodesController < BaseController
|
2019-09-19 00:37:27 +10:00
|
|
|
include ChallengableConcern
|
|
|
|
|
2020-09-12 04:56:35 +10:00
|
|
|
skip_before_action :require_functional!
|
2017-04-22 12:23:17 +10:00
|
|
|
|
2019-09-19 00:37:27 +10:00
|
|
|
before_action :require_challenge!, on: :create
|
2017-04-22 12:23:17 +10:00
|
|
|
|
|
|
|
def create
|
|
|
|
@recovery_codes = current_user.generate_otp_backup_codes!
|
|
|
|
current_user.save!
|
2019-09-19 00:37:27 +10:00
|
|
|
|
|
|
|
UserMailer.two_factor_recovery_codes_changed(current_user).deliver_later!
|
2019-07-20 07:13:21 +10:00
|
|
|
flash.now[:notice] = I18n.t('two_factor_authentication.recovery_codes_regenerated')
|
2019-09-19 00:37:27 +10:00
|
|
|
|
2017-04-22 12:23:17 +10:00
|
|
|
render :index
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|