mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 01:27:32 +00:00
chore: move the go code into a subfolder
This commit is contained in:
38
apps/api/internal/command/user_v2_username.go
Normal file
38
apps/api/internal/command/user_v2_username.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/repository/user"
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
)
|
||||
|
||||
func (c *Commands) changeUsername(ctx context.Context, cmds []eventstore.Command, wm *UserV2WriteModel, userName string) ([]eventstore.Command, error) {
|
||||
if wm.UserName == userName {
|
||||
return cmds, nil
|
||||
}
|
||||
orgID := wm.ResourceOwner
|
||||
|
||||
domainPolicy, err := c.domainPolicyWriteModel(ctx, orgID)
|
||||
if err != nil {
|
||||
return cmds, zerrors.ThrowPreconditionFailed(err, "COMMAND-79pv6e1q62", "Errors.Org.DomainPolicy.NotExisting")
|
||||
}
|
||||
|
||||
organizationScopedUsername, err := c.checkOrganizationScopedUsernames(ctx, orgID)
|
||||
if err != nil {
|
||||
return cmds, err
|
||||
}
|
||||
|
||||
if err = c.userValidateDomain(ctx, orgID, userName, domainPolicy.UserLoginMustBeDomain); err != nil {
|
||||
return cmds, err
|
||||
}
|
||||
return append(cmds,
|
||||
user.NewUsernameChangedEvent(ctx, &wm.Aggregate().Aggregate,
|
||||
wm.UserName,
|
||||
userName,
|
||||
domainPolicy.UserLoginMustBeDomain,
|
||||
organizationScopedUsername,
|
||||
),
|
||||
), nil
|
||||
}
|
Reference in New Issue
Block a user