fix: user with state initial can only be deleted not deactivated (#3110)

This commit is contained in:
Fabi
2022-01-25 11:54:36 +01:00
committed by GitHub
parent 159d82ad8e
commit ce53fe7814
5 changed files with 10 additions and 0 deletions

View File

@@ -70,6 +70,9 @@ func (c *Commands) DeactivateUser(ctx context.Context, userID, resourceOwner str
if !isUserStateExists(existingUser.UserState) {
return nil, caos_errs.ThrowNotFound(nil, "COMMAND-3M9ds", "Errors.User.NotFound")
}
if isUserStateInitial(existingUser.UserState) {
return nil, caos_errs.ThrowNotFound(nil, "COMMAND-ke0fw", "Errors.User.CantDeactivateInitial")
}
if isUserStateInactive(existingUser.UserState) {
return nil, caos_errs.ThrowPreconditionFailed(nil, "COMMAND-5M0sf", "Errors.User.AlreadyInactive")
}