summaryrefslogtreecommitdiff
path: root/app/controllers/sessions_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/sessions_controller.rb')
-rw-r--r--app/controllers/sessions_controller.rb20
1 files changed, 17 insertions, 3 deletions
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
index 64bf951a..f0d5cf9b 100644
--- a/app/controllers/sessions_controller.rb
+++ b/app/controllers/sessions_controller.rb
@@ -20,9 +20,23 @@ class SessionsController < ApplicationController
20 # button. Uncomment if you understand the tradeoffs. 20 # button. Uncomment if you understand the tradeoffs.
21 reset_session 21 reset_session
22 22
23 self.current_user = user 23 if user.otp_enrolled?
24 redirect_to safe_return_to(return_to, :default => admin_path) 24 # Half-completed login: no user_id yet, only the pending marker.
25 flash[:notice] = "Logged in successfully" 25 session[:pending_otp_user_id] = user.id
26 session[:otp_deadline] = 2.minutes.from_now.to_i
27 session[:otp_attempts] = 0
28 session[:return_to] = return_to
29 redirect_to new_otp_challenge_path
30 else
31 self.current_user = user
32 if user.otp_required?
33 flash[:error] = "Your account requires a second factor -- set it up now."
34 redirect_to edit_user_path(user)
35 else
36 flash[:notice] = "Logged in successfully"
37 redirect_to safe_return_to(return_to, :default => admin_path)
38 end
39 end
26 else 40 else
27 note_failed_signin 41 note_failed_signin
28 @login = params[:login] 42 @login = params[:login]