Class: QuoVadis::RecoveryCodesController

Inherits:
QuoVadisController show all
Defined in:
app/controllers/quo_vadis/recovery_codes_controller.rb

Instance Method Summary collapse

Instance Method Details

#authenticateObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/quo_vadis/recovery_codes_controller.rb', line 18

def authenticate
  if .recovery_codes.detect { |rc| rc.authenticate_code params[:code] }
    qv.log , Log::RECOVERY_CODE_SUCCESS
    qv.replace_session
    qv.session_authenticated_with_second_factor
    reset_totp
    redirect_to qv.path_after_authentication,
      notice: QuoVadis.translate('flash.recovery_code.success',
                                 count: .recovery_codes.count)
  else
    qv.log , Log::RECOVERY_CODE_FAILURE
    flash.now[:alert] = QuoVadis.translate('flash.recovery_code.unverified')
    render :challenge, status: :unprocessable_entity
  end
end

#challengeObject



14
15
# File 'app/controllers/quo_vadis/recovery_codes_controller.rb', line 14

def challenge
end

#generateObject



35
36
37
38
39
40
41
# File 'app/controllers/quo_vadis/recovery_codes_controller.rb', line 35

def generate
  qv.log , Log::RECOVERY_CODE_GENERATE
  QuoVadis.notify :recovery_codes_generation_notification, email: authenticated_model.email
  .recovery_codes.delete_all
  flash[:recovery_codes] = .generate_recovery_codes
  redirect_to quo_vadis.recovery_codes_path
end

#indexObject



8
9
10
11
# File 'app/controllers/quo_vadis/recovery_codes_controller.rb', line 8

def index
  @codes = flash[:recovery_codes]
  @recovery_code_count = .recovery_codes.count
end