Is there are specific reason why wm.CodeReturned leads to Errors.User.Code.NotFound?
if requireExisting && wm.InviteCode == nil || wm.CodeReturned {
return nil, nil, zerrors.ThrowPreconditionFailed(nil, "COMMAND-Wr3gq", "Errors.User.Code.NotFound")
}
https://github.com/zitadel/zitadel/issues/10718
I would like to understand if this is expected behavior or a bug because it's blocking our adoption of zitadel.
Steps:
1. Add new user
2. Create invite code and return code instead of sending
3. Try to login with the new userGitHub
[Bug]: Return invite code produces error in login v2 · Issue #1071...
Preflight Checklist I could not find a solution in the documentation, the existing issues or discussions I have joined the ZITADEL chat Environment Self-hosted Version 4.1.4 Database PostgreSQL Dat...
9 Replies
Hi @Jan, I'm an AI assistant for ZITADEL. While a team member reviews this question, I'll see if I can find relevant sources for your question.
Answer
I wasn't able to find a direct answer, here are some relevant sources:
1. Verify an invite code for a user :
Describes how invite codes are verified and the expected API behavior when verifying a code for a user. 2. Resend an invite code for a user :
Explains the process for resending invite codes and may provide insight into invite code handling. Feel free to tag @Ask Inkeep with additional questions. Got it. Tagging @Rajat for additional help.
Describes how invite codes are verified and the expected API behavior when verifying a code for a user. 2. Resend an invite code for a user :
Explains the process for resending invite codes and may provide insight into invite code handling. Feel free to tag @Ask Inkeep with additional questions. Got it. Tagging @Rajat for additional help.
hey @Jan thanks for your queestion, I will look into this and will get back to you
Hi Rajat, any updates? 🙂
hey @Jan thanks for the ping, looking into it right now
hey @Jan I understood your issue, first of all, its a very neat finding , and second of all, It’s an expected limitation today, if you create the invite with
returnCode , Login V2 can’t “find” a stored invite, so resend/continue fails with Errors.User.Code.NotFound. Something similar was also mentioned on the v1 Resend Invite code api endpointHi Rajat thanks for the update, appreciate it. Do you know what is exactly the reason for the different behaviour? I can see no real difference between sending the invite code and return it to sent it with a custom email from a user perspective. Am I missing something?
yes but from the code, if you look at it, when you "send", it sets
wm.CodeReturned to false, so Login V2 can find it and it can resend/continue.
What returnCode does is it doesnt stores a sendable invite and sets CodeReturned to true, so Login V2 paths that require an existing stored invite treat this as not found so it throws Errors.User.Code.NotFound.Yes from the code perspective it's clear. What I don't unterstand is the different behviour and the expected(?) crash of the login ui if a user tries to login. With returnCode a user always has to use the Code to setup the account but if Zitadel sends the code the user can request a new code without problems using the login ui. Is there any business reason for the different behaviour?
Sorry to be persistent here but if the behviour is intended and wont/can't be changed we have to implement a custom invite and don't use the Zitadel invite codes at all :/
hey @Jan I'd say that this is an intentional limitation of the Login V2 . If this behavior blocks you and you need resend from the UI , choose option one(using
send for invites ) If you need custom emails, imo implement a custom invite flow or Keep returnCode and you send the email/message using your own template or service.🎉 Looks like you just helped out another community member! Thanks for being so helpful <@1346540274674827395>! You're now one step closer to leveling up—keep up the amazing peer support! 🚀