Invite user to organization (signed or unsigned users)
how to handle there cases:
- we invite users to organization but user might not have an account, in that case check the user email and force user to signup then redirect to accept invitation page
- but if user already have an account then redirect to login page if not logged in and then to redirect to accept invitation page
1 Reply
hi @Aadarsha, i did something similar in my application and can be useful to you.
in my
sendInvitationEmail
, I verified the email there I'm sending the invite already exists in my database.
If the answer is negative, I added two params in my invite URL
In my /accept-invitation/[code]
page.tx I did two different verifications,
If I have the param newUser
, I redirect my user to /signup
and them the user can create your account. After receive a positive answer, I redirect my user to /email-verification?email=${email}&code=${searchParams?.code}
and then, I follow the same logic of login: I redirect to /login?&code=${searchParams?.code}
and in my login, if I receive the param code
, after a success login in the application, I redirect my user to /accept-invitation?&code=${searchParams?.code}
again
If I don't but the user doesn't have a valid session, I redirect to /login?&code=${searchParams?.code}
and in my login, if I receive the param code
, after a success login in the application, I redirect my user to /accept-invitation?&code=${searchParams?.code}
again
