Class: Devise::TotpController

Inherits:
DeviseController
  • Object
show all
Defined in:
app/controllers/devise/totp_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/devise/totp_controller.rb', line 13

def create
  @otp_secret_signature = params[:otp_secret_signature]
  @otp_secret = verify_otp_secret(@otp_secret_signature)
  if resource.enroll_totp!(@otp_secret, params[:otp_attempt])
    after_two_factor_enroll_success_for(resource)
  else
    flash.now[:error] = I18n.t('devise.totp_setup.invalid_code')
    render_enroll_form(status: :unprocessable_entity)
  end
rescue ActiveSupport::MessageVerifier::InvalidSignature
  redirect_to send("new_#{resource_name}_two_factor_authentication_path"), flash: { error: I18n.t('devise.totp_setup.invalid_signature') }
end

#destroyObject



29
30
# File 'app/controllers/devise/totp_controller.rb', line 29

def destroy
end

#newObject



7
8
9
10
11
# File 'app/controllers/devise/totp_controller.rb', line 7

def new
  @otp_secret = resource.generate_totp_secret
  @otp_secret_signature = sign_otp_secret(@otp_secret)
  render_enroll_form
end

#showObject



26
27
# File 'app/controllers/devise/totp_controller.rb', line 26

def show
end