GetByKeyID returns the owner of given public key ID. It returns ErrUserNotExist when not found.
(ctx context.Context, keyID int64)
| 758 | // GetByKeyID returns the owner of given public key ID. It returns |
| 759 | // ErrUserNotExist when not found. |
| 760 | func (s *UsersStore) GetByKeyID(ctx context.Context, keyID int64) (*User, error) { |
| 761 | user := new(User) |
| 762 | err := s.db.WithContext(ctx). |
| 763 | Joins(dbutil.Quote("JOIN public_key ON public_key.owner_id = %s.id", "user")). |
| 764 | Where("public_key.id = ?", keyID). |
| 765 | First(user). |
| 766 | Error |
| 767 | if err != nil { |
| 768 | if errors.Is(err, gorm.ErrRecordNotFound) { |
| 769 | return nil, ErrUserNotExist{args: errutil.Args{"keyID": keyID}} |
| 770 | } |
| 771 | return nil, err |
| 772 | } |
| 773 | return user, nil |
| 774 | } |
| 775 | |
| 776 | // GetMailableEmailsByUsernames returns a list of verified primary email |
| 777 | // addresses (where email notifications are sent to) of users with given list of |