8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'app/controllers/devise/two_factor_authentication_controller.rb', line 8
def update
render :show and return if params[:code].nil?
if resource.authenticate_otp(params[:code])
warden.session(resource_name)[TwoFactorAuthentication::NEED_AUTHENTICATION] = false
sign_in resource_name, resource, :bypass => true
set_flash_message :notice, :success
redirect_to stored_location_for(resource_name) || :root
resource.update_attribute(:second_factor_attempts_count, 0)
else
resource.second_factor_attempts_count += 1
resource.save
flash.now[:error] = find_message(:attempt_failed)
if resource.max_login_attempts?
sign_out(resource)
render :max_login_attempts_reached
else
render :show
end
end
end
|