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