Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I send different invites on same email? #869

Open
oakbani opened this issue Feb 16, 2022 · 1 comment
Open

How do I send different invites on same email? #869

oakbani opened this issue Feb 16, 2022 · 1 comment

Comments

@oakbani
Copy link

oakbani commented Feb 16, 2022

I have two models in my application. User and SubUsers. A sub user can belong to multiple users. This means that it is possible that
a User A invites email abc@gmail.com to his portal. And at the same time,
a User B invites email abc@gmail.com to his portal.

Given the current behavior it looks like that only a single invite can be sent to each email at a time. How do I manage this particular scenario?

@scambra
Copy link
Owner

scambra commented Mar 1, 2022

I would need more info about what fields User and SubUser have, and how relationships are built. When abc@gmail.com accepts invitation, does it create a User or SubUser? where is email saved?

I think you need to different type of invitations, the invitation from this gem, asking to register and join portal, for first invitation (email doesn't exist yet), and another one asking for joining to a portal for emails which are already registered (they have password).

I guess you need to override the invitations controller, or have a custom invitation action. If user with email exists, then send an email to request user join to a portal, accepting this invitation would be a different action. If user doesn't exist, you could call User.invite! to invite user to join, accepting invitation would use invitation action from this gem. Or you could call User.invite!, if it returns an user with errors, it means user exist and no email was sent, then you can send your own email to ask for joining a portal.

When user doesn't exist, and User A send an invitation, and User B sends another invitation before previous invitation is accepted, invitation token would be overrided. First email will have an invalid invitation token now, accepting second invitation would set the password, and it may join to both portals, depending on your implementation.

I would like to save invitations in a separate table, as requested on issues #388 and and #228, it may help with your request, but I never had time to work on that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants