about summary refs log tree commit diff
path: root/app/controllers/auth
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-04-06 21:10:23 +0200
committerClaire <claire.github-309c@sitedethib.com>2022-04-06 21:10:23 +0200
commitb368c7502931aa06121ecad8a97193b1f17cf90a (patch)
tree2b598363926388d30a4c5c6197436b46f6d4610a /app/controllers/auth
parent00c9363f07081e0149533023992fba47dd905384 (diff)
parentdd4c156f33a24b8bb89b45b2697aa4036c3ae5be (diff)
Merge branch 'main' into glitch-soc/merge-upstream
Conflicts:
- `app/controllers/concerns/sign_in_token_authentication_concern.rb`:
  Upstream removed this file, while glitch-soc had changes to deal with
  its theming system.
  Removed the file like upstream did.
Diffstat (limited to 'app/controllers/auth')
-rw-r--r--app/controllers/auth/sessions_controller.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/app/controllers/auth/sessions_controller.rb b/app/controllers/auth/sessions_controller.rb
index 8607077f7..056f8a9f1 100644
--- a/app/controllers/auth/sessions_controller.rb
+++ b/app/controllers/auth/sessions_controller.rb
@@ -10,7 +10,6 @@ class Auth::SessionsController < Devise::SessionsController
   prepend_before_action :set_pack
 
   include TwoFactorAuthenticationConcern
-  include SignInTokenAuthenticationConcern
 
   before_action :set_instance_presenter, only: [:new]
   before_action :set_body_classes
@@ -68,7 +67,7 @@ class Auth::SessionsController < Devise::SessionsController
   end
 
   def user_params
-    params.require(:user).permit(:email, :password, :otp_attempt, :sign_in_token_attempt, credential: {})
+    params.require(:user).permit(:email, :password, :otp_attempt, credential: {})
   end
 
   def after_sign_in_path_for(resource)
@@ -148,6 +147,12 @@ class Auth::SessionsController < Devise::SessionsController
       ip: request.remote_ip,
       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)
+  end
+
+  def suspicious_sign_in?(user)
+    SuspiciousSignInDetector.new(user).suspicious?(request)
   end
 
   def on_authentication_failure(user, security_measure, failure_reason)