fix: allow creating new invite code before previous is invalid (#11649)

# Which Problems Are Solved

In the refactoring of the logic for the creating and resending of invite
codes (#9962), a bug was introduced where the creating of a new code was
not possible if the request was to return it. It worked when being sent
via mail.

# How the Problems Are Solved

Fixed the check for an existing code.

# Additional Changes

none

# Additional Context

- closes https://github.com/zitadel/zitadel/issues/10718
- requires backport to v4.x
- relates to #9962

Co-authored-by: Marco A. <[email protected]>
This commit is contained in:
Livio Spring
2026-02-20 12:34:07 +00:00
committed by GitHub
co-authored by Marco A.
parent df8824e16c
commit afeeee87c3
2 changed files with 81 additions and 1 deletions
+1 -1
View File
@@ -62,7 +62,7 @@ func (c *Commands) sendInviteCode(ctx context.Context, invite *CreateUserInvite,
if !wm.CreationAllowed() {
return nil, nil, zerrors.ThrowPreconditionFailed(nil, "COMMAND-EF34g", "Errors.User.AlreadyInitialised")
}
if requireExisting && wm.InviteCode == nil || wm.CodeReturned {
if requireExisting && (wm.InviteCode == nil || wm.CodeReturned) {
return nil, nil, zerrors.ThrowPreconditionFailed(nil, "COMMAND-Wr3gq", "Errors.User.Code.NotFound")
}
code, err := c.newUserInviteCode(ctx, c.eventstore.Filter, c.userEncryption) //nolint