discourse/app/jobs/regular/suspicious_login.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

25 lines
605 B
Ruby
Raw Normal View History

# frozen_string_literal: true
module Jobs
class SuspiciousLogin < ::Jobs::Base
def execute(args)
if UserAuthToken.is_suspicious(args[:user_id], args[:client_ip])
UserAuthToken.log(
action: "suspicious",
user_id: args[:user_id],
user_agent: args[:user_agent],
client_ip: args[:client_ip],
)
::Jobs.enqueue(
:critical_user_email,
type: "suspicious_login",
user_id: args[:user_id],
client_ip: args[:client_ip],
user_agent: args[:user_agent],
)
end
end
end
end