1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

fix: add missing non-zero field checks (fix #259)

This commit is contained in:
Ferdinand Mütsch
2021-10-11 11:07:04 +02:00
parent 8d073aaef2
commit cc11226eab
4 changed files with 21 additions and 0 deletions

View File

@@ -35,6 +35,9 @@ func (r *UserRepository) GetByIds(userIds []string) ([]*models.User, error) {
}
func (r *UserRepository) GetByApiKey(key string) (*models.User, error) {
if key == "" {
return nil, errors.New("invalid input")
}
u := &models.User{}
if err := r.db.Where(&models.User{ApiKey: key}).First(u).Error; err != nil {
return u, err