2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-10-25 05:45:31 -04:00
|
|
|
module Jobs
|
2019-10-02 00:01:53 -04:00
|
|
|
class SuspiciousLogin < ::Jobs::Base
|
2018-10-25 05:45:31 -04:00
|
|
|
def execute(args)
|
|
|
|
if UserAuthToken.is_suspicious(args[:user_id], args[:client_ip])
|
2023-01-09 07:20:10 -05:00
|
|
|
UserAuthToken.log(
|
|
|
|
action: "suspicious",
|
|
|
|
user_id: args[:user_id],
|
|
|
|
user_agent: args[:user_agent],
|
|
|
|
client_ip: args[:client_ip],
|
|
|
|
)
|
2018-10-30 18:51:58 -04:00
|
|
|
|
2023-01-09 07:20:10 -05:00
|
|
|
::Jobs.enqueue(
|
|
|
|
:critical_user_email,
|
|
|
|
type: "suspicious_login",
|
|
|
|
user_id: args[:user_id],
|
|
|
|
client_ip: args[:client_ip],
|
|
|
|
user_agent: args[:user_agent],
|
|
|
|
)
|
2018-10-25 05:45:31 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|