2018-09-14 01:42:05 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-05-17 05:19:47 -04:00
|
|
|
module AcceptsPendingInvitations
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
2022-08-12 11:11:42 -04:00
|
|
|
def accept_pending_invitations(user: resource)
|
|
|
|
return unless user.active_for_authentication?
|
2018-05-17 05:19:47 -04:00
|
|
|
|
2022-08-12 11:11:42 -04:00
|
|
|
if user.pending_invitations.load.any?
|
|
|
|
user.accept_pending_invitations!
|
|
|
|
clear_stored_location_for(user: user)
|
2021-04-29 17:10:03 -04:00
|
|
|
after_pending_invitations_hook
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def after_pending_invitations_hook
|
|
|
|
# no-op
|
2018-05-17 05:19:47 -04:00
|
|
|
end
|
|
|
|
|
2022-08-12 11:11:42 -04:00
|
|
|
def clear_stored_location_for(user:)
|
|
|
|
session_key = stored_location_key_for(user)
|
2018-05-17 05:19:47 -04:00
|
|
|
|
|
|
|
session.delete(session_key)
|
|
|
|
end
|
|
|
|
end
|