(u *user.User)
| 34 | } |
| 35 | |
| 36 | func (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 | |
| 74 | func (m *UserManager) UpdateUser(id string, uu *user.UpdateUser) (*user.User, error) { |
| 75 | uu.UpdatedAt = time.Now().Unix() |
nothing calls this directly
no test coverage detected