1
0
Fork 0
This repository has been archived on 2023-03-27. You can view files and clone it, but cannot push or open issues or pull requests.
lpr-partynest/app/interactors/log_user_session.rb

33 lines
650 B
Ruby

# frozen_string_literal: true
class LogUserSession
include Interactor
def call
create_session
send_alerts
end
private
def contacts
@contacts ||= context.user.account.contact_list.contacts
.where(send_security_notifications: true)
end
def create_session
@session = Session.create!(
account: context.user.account,
logged_at: context.user.current_sign_in_at,
ip_address: context.user.current_sign_in_ip,
)
end
def send_alerts
contacts.each do |contact|
NotificationMailer.signed_in(contact.value, @session).deliver_now
rescue
nil
end
end
end