FindUserByID retrieves a user by ID along with their associated auth objects. Returns ENOTFOUND if user does not exist.
(ctx context.Context, id int)
| 28 | // FindUserByID retrieves a user by ID along with their associated auth objects. |
| 29 | // Returns ENOTFOUND if user does not exist. |
| 30 | func (s *UserService) FindUserByID(ctx context.Context, id int) (*wtf.User, error) { |
| 31 | tx, err := s.db.BeginTx(ctx, nil) |
| 32 | if err != nil { |
| 33 | return nil, err |
| 34 | } |
| 35 | defer tx.Rollback() |
| 36 | |
| 37 | // Fetch user and their associated OAuth objects. |
| 38 | user, err := findUserByID(ctx, tx, id) |
| 39 | if err != nil { |
| 40 | return nil, err |
| 41 | } else if err := attachUserAuths(ctx, tx, user); err != nil { |
| 42 | return user, err |
| 43 | } |
| 44 | return user, nil |
| 45 | } |
| 46 | |
| 47 | // FindUsers retrieves a list of users by filter. Also returns total count of |
| 48 | // matching users which may differ from returned results if filter.Limit is specified. |