mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 19:07:30 +00:00
fix(import/export): fix for deactivated user/organization being imported as active (#9992)
This commit is contained in:
@@ -79,7 +79,7 @@ func AddMachineWithUsernameToIDFallback() addMachineOption {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Commands) AddMachine(ctx context.Context, machine *Machine, check PermissionCheck, options ...addMachineOption) (_ *domain.ObjectDetails, err error) {
|
||||
func (c *Commands) AddMachine(ctx context.Context, machine *Machine, state *domain.UserState, check PermissionCheck, options ...addMachineOption) (_ *domain.ObjectDetails, err error) {
|
||||
ctx, span := tracing.NewSpan(ctx)
|
||||
defer func() { span.EndWithError(err) }()
|
||||
|
||||
@@ -107,6 +107,29 @@ func (c *Commands) AddMachine(ctx context.Context, machine *Machine, check Permi
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if state != nil {
|
||||
var cmd eventstore.Command
|
||||
switch *state {
|
||||
case domain.UserStateInactive:
|
||||
cmd = user.NewUserDeactivatedEvent(ctx, &agg.Aggregate)
|
||||
case domain.UserStateLocked:
|
||||
cmd = user.NewUserLockedEvent(ctx, &agg.Aggregate)
|
||||
case domain.UserStateDeleted:
|
||||
// users are never imported if deleted
|
||||
case domain.UserStateActive:
|
||||
// added because of the linter
|
||||
case domain.UserStateSuspend:
|
||||
// added because of the linter
|
||||
case domain.UserStateInitial:
|
||||
// added because of the linter
|
||||
case domain.UserStateUnspecified:
|
||||
// added because of the linter
|
||||
}
|
||||
if cmd != nil {
|
||||
cmds = append(cmds, cmd)
|
||||
}
|
||||
}
|
||||
|
||||
events, err := c.eventstore.Push(ctx, cmds...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
Reference in New Issue
Block a user