Invite a user to register using the org's Idps
Hello, I want to invite a user from my backend app to join an organization (Use Zitadel api to create the user and then add him to the org, also add him to a team table in my backend app) , and I want to redirect him to a page where he can register using External providers only, Is it possible to do this ? I found this api method "Start flow with an identity provider" but I have to specify the identity provider, Is there any other way to do this ?
1 Reply
I think i might have found a solution:
- First i'll create an invitation in my db containing token and email, and I'll send the token to the user email inside the url of my accept invitation endpoint in my app.
- after the user clicks the link I will search the token in the db, and if found with the correct email as well i'll redirect the user to the login page
- the login page will contain 2 buttons, Microsoft login and google login, if the user clicks in one of them ( both contain the invitation token as a param), I'll call an endpoint in my app that gets the idp id and invitation token and then start a flow with that idp in zitadel, when i get the auth url i will redirect the user to that auth url and save the intent id and intent token on the invitation table of that inv token.
- After a success login, the idp will auto call the success url (that contains the invitation id) i provided and then when the endpoint is hit i'll search for that invitation id again and get the intent id from my inv table and search for the intent in zitadel and get the user info and then create the user.
what do you think?