Class: TwoFactorAuth::AuthenticationsController
Instance Method Summary
collapse
#authentication_request, #clear_pending_authentication_challenge, #two_factor_auth_authentication, #user_two_factor_auth_authenticated!, #user_two_factor_auth_authenticated?
Instance Method Details
#create ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'app/controllers/two_factor_auth/authentications_controller.rb', line 12
def create
keyHandle = TwoFactorAuth::websafe_base64_decode(params.fetch(:keyHandle, ''))
registration = Registration.find_by_key_handle(keyHandle)
verifier = AuthenticationVerifier.new({
registration: registration,
request: authentication_request,
client_data: ClientData.new(encoded: params[:clientData], correct_typ: 'navigator.id.getAssertion'),
response: AuthenticationResponse.new(encoded: params[:signatureData]),
})
clear_pending_authentication_challenge
if verifier.valid?
user_two_factor_auth_authenticated! verifier.counter
redirect_to after_sign_in_path_for(current_user)
else
flash[:alert] = "Unable to authenticate"
render :new, status: 406
end
end
|
#new ⇒ Object
8
9
10
|
# File 'app/controllers/two_factor_auth/authentications_controller.rb', line 8
def new
redirect_to after_sign_in_path_for(current_user) if user_two_factor_auth_authenticated?
end
|