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])
|
2018-10-30 18:51:58 -04:00
|
|
|
UserAuthToken.log(
|
|
|
|
action: "suspicious",
|
|
|
|
user_id: args[:user_id],
|
|
|
|
user_agent: args[:user_agent],
|
2018-10-25 05:45:31 -04:00
|
|
|
client_ip: args[:client_ip],
|
2023-01-09 07:20:10 -05:00
|
|
|
)
|
2018-10-30 18:51:58 -04:00
|
|
|
|
2019-10-21 13:25:35 -04:00
|
|
|
::Jobs.enqueue(
|
|
|
|
:critical_user_email,
|
2022-02-04 12:34:38 -05:00
|
|
|
type: "suspicious_login",
|
2018-10-25 05:45:31 -04:00
|
|
|
user_id: args[:user_id],
|
|
|
|
client_ip: args[:client_ip],
|
|
|
|
user_agent: args[:user_agent],
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|