MCPcopy Create free account
hub / github.com/bricks-cloud/BricksLLM / CreateUser

Method CreateUser

internal/manager/user.go:36–72  ·  view source on GitHub ↗
(u *user.User)

Source from the content-addressed store, hash-verified

34}
35
36func (m *UserManager) CreateUser(u *user.User) (*user.User, error) {
37 u.CreatedAt = time.Now().Unix()
38 u.UpdatedAt = time.Now().Unix()
39 u.Id = util.NewUuid()
40
41 if err := u.Validate(); err != nil {
42 return nil, err
43 }
44
45 if len(u.UserId) != 0 {
46 existing, err := m.us.GetUsers(u.Tags, nil, []string{u.UserId}, 0, 0)
47 if err != nil {
48 return nil, err
49 }
50
51 if len(existing) != 0 {
52 return nil, internal_errors.NewValidationError(fmt.Sprintf("user id exists for tags: [%s]", strings.Join(u.Tags, ",")))
53 }
54 }
55
56 if len(u.UserId) == 0 {
57 u.UserId = util.NewUuid()
58 }
59
60 if len(u.KeyIds) != 0 {
61 existing, err := m.ks.GetKeys(nil, u.KeyIds, "")
62 if err != nil {
63 return nil, err
64 }
65
66 if len(existing) == 0 {
67 return nil, internal_errors.NewNotFoundError("keys are not found")
68 }
69 }
70
71 return m.us.CreateUser(u)
72}
73
74func (m *UserManager) UpdateUser(id string, uu *user.UpdateUser) (*user.User, error) {
75 uu.UpdatedAt = time.Now().Unix()

Callers

nothing calls this directly

Implementers 2

Storeinternal/storage/postgresql/postgresql
UserManagerinternal/manager/user.go

Calls 5

NewUuidFunction · 0.92
ValidateMethod · 0.65
GetUsersMethod · 0.65
GetKeysMethod · 0.65
CreateUserMethod · 0.65

Tested by

no test coverage detected