feat: add declaritive user id configuration (#1622)

This commit is contained in:
Markus Schanz
2026-07-25 23:43:16 +02:00
committed by GitHub
parent 8563934fd5
commit 80c7c4aaf1
3 changed files with 16 additions and 0 deletions
+1
View File
@@ -23,6 +23,7 @@ type UserDto struct {
}
type UserCreateDto struct {
ID string `json:"id" binding:"omitempty,uuid"`
Username string `json:"username" binding:"required,username,min=1,max=50" unorm:"nfc"`
Email *string `json:"email" binding:"omitempty,email" unorm:"nfc"`
EmailVerified bool `json:"emailVerified"`
+12
View File
@@ -23,6 +23,18 @@ func TestUserCreateDto_Validate(t *testing.T) {
},
wantErr: "",
},
{
name: "with custom id",
input: UserCreateDto{
ID: "e8b81981-1c92-46e3-bfbf-07096560e6bb",
Username: "testuser",
Email: new("test@example.com"),
FirstName: "John",
LastName: "Doe",
DisplayName: "John Doe",
},
wantErr: "",
},
{
name: "missing username",
input: UserCreateDto{
+3
View File
@@ -285,6 +285,9 @@ func (s *UserService) createUserInternal(ctx context.Context, input dto.UserCrea
Disabled: input.Disabled,
UserGroups: userGroups,
}
if input.ID != "" {
user.ID = input.ID
}
if input.LdapID != "" {
user.LdapID = &input.LdapID
}