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