2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
module AcceptsPendingInvitations
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
def accept_pending_invitations(user: resource)
|
|
|
|
return unless user.active_for_authentication?
|
2018-11-08 19:23:39 +05:30
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
if user.pending_invitations.load.any?
|
|
|
|
user.accept_pending_invitations!
|
|
|
|
clear_stored_location_for(user: user)
|
2021-06-08 01:23:25 +05:30
|
|
|
after_pending_invitations_hook
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def after_pending_invitations_hook
|
|
|
|
# no-op
|
2018-11-08 19:23:39 +05:30
|
|
|
end
|
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
def clear_stored_location_for(user:)
|
|
|
|
session_key = stored_location_key_for(user)
|
2018-11-08 19:23:39 +05:30
|
|
|
|
|
|
|
session.delete(session_key)
|
|
|
|
end
|
|
|
|
end
|