diff options
author | Claire <claire.github-309c@sitedethib.com> | 2022-06-29 18:27:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-29 18:27:34 +0200 |
commit | 54ed35f57c55fff639c8192b99fc60ab69c54f06 (patch) | |
tree | 78cee27bfe871569f3ae2e7aa62d847fe9df7046 /app/controllers/auth/sessions_controller.rb | |
parent | 63f79874b59b3ba28c0f940b9d36ea7aacb44c93 (diff) | |
parent | 485b43ed7e312ab2c3bad446132c57d6a0ce7de4 (diff) |
Merge pull request #1801 from ClearlyClaire/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/controllers/auth/sessions_controller.rb')
-rw-r--r-- | app/controllers/auth/sessions_controller.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/app/controllers/auth/sessions_controller.rb b/app/controllers/auth/sessions_controller.rb index 056f8a9f1..13dfebcdd 100644 --- a/app/controllers/auth/sessions_controller.rb +++ b/app/controllers/auth/sessions_controller.rb @@ -8,12 +8,18 @@ class Auth::SessionsController < Devise::SessionsController skip_before_action :update_user_sign_in prepend_before_action :set_pack + prepend_before_action :check_suspicious!, only: [:create] include TwoFactorAuthenticationConcern before_action :set_instance_presenter, only: [:new] before_action :set_body_classes + def check_suspicious! + user = find_user + @login_is_suspicious = suspicious_sign_in?(user) unless user.nil? + end + def create super do |resource| # We only need to call this if this hasn't already been @@ -148,7 +154,7 @@ class Auth::SessionsController < Devise::SessionsController user_agent: request.user_agent ) - UserMailer.suspicious_sign_in(user, request.remote_ip, request.user_agent, Time.now.utc).deliver_later! if suspicious_sign_in?(user) + UserMailer.suspicious_sign_in(user, request.remote_ip, request.user_agent, Time.now.utc).deliver_later! if @login_is_suspicious end def suspicious_sign_in?(user) |