mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 02:54:20 +00:00
fix: user with state initial can only be deleted not deactivated (#3110)
This commit is contained in:
parent
159d82ad8e
commit
ce53fe7814
@ -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")
|
||||
}
|
||||
|
@ -140,6 +140,10 @@ func isUserStateInactive(state domain.UserState) bool {
|
||||
return hasUserState(state, domain.UserStateInactive)
|
||||
}
|
||||
|
||||
func isUserStateInitial(state domain.UserState) bool {
|
||||
return hasUserState(state, domain.UserStateInitial)
|
||||
}
|
||||
|
||||
func hasUserState(check domain.UserState, states ...domain.UserState) bool {
|
||||
for _, state := range states {
|
||||
if check == state {
|
||||
|
@ -39,6 +39,7 @@ Errors:
|
||||
DomainNotAllowedAsUsername: Domäne ist bereits reserviert und kann nicht verwendet werden
|
||||
AlreadyInactive: Benutzer ist bereits deaktiviert
|
||||
NotInactive: Benutzer ist nicht inaktiv
|
||||
CantDeactivateInitial: Benutzer mit dem Status initial kann nur gelöscht und nicht deaktiviert werden
|
||||
ShouldBeActiveOrInitial: Benutzer ist nicht aktiv oder initialisiert
|
||||
AlreadyInitialised: Benutzer ist bereits initialisiert
|
||||
NotInitialised: Benutzer ist noch nicht initialisiert
|
||||
|
@ -39,6 +39,7 @@ Errors:
|
||||
DomainNotAllowedAsUsername: Domain is already reserved and cannot be used
|
||||
AlreadyInactive: User already inactive
|
||||
NotInactive: User is not inactive
|
||||
CantDeactivateInitial: User with state initial can only be deleted not deactivated
|
||||
ShouldBeActiveOrInitial: User is not active or inital
|
||||
AlreadyInitialised: User is already initialised
|
||||
NotInitialised: User is not yet initialised
|
||||
|
@ -39,6 +39,7 @@ Errors:
|
||||
DomainNotAllowedAsUsername: Il dominio è già riservato e non può essere utilizzato
|
||||
AlreadyInactive: Utente già inattivo
|
||||
NotInactive: L'utente non è inattivo
|
||||
CantDeactivateInitial: Gli utenti con lo stato iniziale possono solo essere cancellati e non disattivati
|
||||
ShouldBeActiveOrInitial: L'utente non è attivo o inizializzato
|
||||
AlreadyInitialised: L'utente è già inizializzato
|
||||
NotInitialised: L'utente non è ancora inizializzato
|
||||
|
Loading…
Reference in New Issue
Block a user