|
|
@ -20,9 +20,14 @@ module TwoFactorAuthentication |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def handle_failed_second_factor(scope) |
|
|
|
def handle_failed_second_factor(scope) |
|
|
|
if request.format.present? and request.format.html? |
|
|
|
if request.format.present? |
|
|
|
|
|
|
|
if request.format.html? |
|
|
|
session["#{scope}_return_to"] = request.original_fullpath if request.get? |
|
|
|
session["#{scope}_return_to"] = request.original_fullpath if request.get? |
|
|
|
redirect_to two_factor_authentication_path_for(scope) |
|
|
|
redirect_to two_factor_authentication_path_for(scope) |
|
|
|
|
|
|
|
elsif request.format.json? |
|
|
|
|
|
|
|
session["#{scope}_return_to"] = root_path(format: :html) |
|
|
|
|
|
|
|
render json: { redirect_to: two_factor_authentication_path_for(scope) }, status: :unauthorized |
|
|
|
|
|
|
|
end |
|
|
|
else |
|
|
|
else |
|
|
|
head :unauthorized |
|
|
|
head :unauthorized |
|
|
|
end |
|
|
|
end |
|
|
|