summaryrefslogtreecommitdiff
path: root/app/controllers/concerns/authenticates_with_two_factor.rb
diff options
context:
space:
mode:
authorhttp://jneen.net/ <jneen@jneen.net>2017-02-28 13:19:52 -0800
committerhttp://jneen.net/ <jneen@jneen.net>2017-03-09 11:49:52 -0800
commit0ea04cc5bfcc125875a6e0f46702389f0e2e19c0 (patch)
treed5cb804a8ce4c5a28bd9cc40724fc96457c29e7f /app/controllers/concerns/authenticates_with_two_factor.rb
parentd9cfed07cd1048328499ae06807368be29bdeb2c (diff)
downloadgitlab-ce-0ea04cc5bfcc125875a6e0f46702389f0e2e19c0.tar.gz
use the policy stack to protect logins
Diffstat (limited to 'app/controllers/concerns/authenticates_with_two_factor.rb')
-rw-r--r--app/controllers/concerns/authenticates_with_two_factor.rb7
1 files changed, 3 insertions, 4 deletions
diff --git a/app/controllers/concerns/authenticates_with_two_factor.rb b/app/controllers/concerns/authenticates_with_two_factor.rb
index 4c497711fc0..ea441b1736b 100644
--- a/app/controllers/concerns/authenticates_with_two_factor.rb
+++ b/app/controllers/concerns/authenticates_with_two_factor.rb
@@ -23,7 +23,7 @@ module AuthenticatesWithTwoFactor
#
# Returns nil
def prompt_for_two_factor(user)
- return locked_user_redirect(user) if user.access_locked?
+ return locked_user_redirect(user) unless user.can?(:log_in)
session[:otp_user_id] = user.id
setup_u2f_authentication(user)
@@ -37,10 +37,9 @@ module AuthenticatesWithTwoFactor
def authenticate_with_two_factor
user = self.resource = find_user
+ return locked_user_redirect(user) unless user.can?(:log_in)
- if user.access_locked?
- locked_user_redirect(user)
- elsif user_params[:otp_attempt].present? && session[:otp_user_id]
+ if user_params[:otp_attempt].present? && session[:otp_user_id]
authenticate_with_two_factor_via_otp(user)
elsif user_params[:device_response].present? && session[:otp_user_id]
authenticate_with_two_factor_via_u2f(user)