fix: use correct check for user existing on import (#8907)

# Which Problems Are Solved

- ImportHuman was not checking for a `UserStateDeleted` state on import,
resulting in "already existing" errors when attempting to delete and
re-import a user with the same id

# How the Problems Are Solved

Use the `Exists` helper method to check for both `UserStateUnspecified`
and `UserStateDeleted` states on import

# Additional Changes

N/A

# Additional Context

N/A

Co-authored-by: Livio Spring <livio.a@gmail.com>
This commit is contained in:
Zach Hirschtritt 2024-11-15 01:46:33 -05:00 committed by GitHub
parent 374b9a7f66
commit 7ba797b872
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -448,7 +448,7 @@ func (c *Commands) ImportHuman(ctx context.Context, orgID string, human *domain.
return nil, nil, err
}
if existing.UserState != domain.UserStateUnspecified {
if existing.UserState.Exists() {
return nil, nil, zerrors.ThrowPreconditionFailed(nil, "COMMAND-ziuna", "Errors.User.AlreadyExisting")
}
}