fix: proper error message when user (and other objects) not found (#337)

* fix: proper error message when user not found by loginname

* add more not found and fix some typos
This commit is contained in:
Livio Amstutz
2020-07-06 13:18:10 +02:00
committed by GitHub
parent b7298bed1e
commit 26634505ba
17 changed files with 90 additions and 5 deletions

View File

@@ -1,6 +1,7 @@
package view
import (
caos_errs "github.com/caos/zitadel/internal/errors"
usr_model "github.com/caos/zitadel/internal/user/model"
"github.com/caos/zitadel/internal/user/repository/view/model"
"github.com/caos/zitadel/internal/view/repository"
@@ -11,6 +12,9 @@ func NotifyUserByID(db *gorm.DB, table, userID string) (*model.NotifyUser, error
user := new(model.NotifyUser)
query := repository.PrepareGetByKey(table, model.UserSearchKey(usr_model.NotifyUserSearchKeyUserID), userID)
err := query(db, user)
if caos_errs.IsNotFound(err) {
return nil, caos_errs.ThrowNotFound(nil, "VIEW-Gad31", "Errors.User.NotFound")
}
return user, err
}

View File

@@ -1,6 +1,7 @@
package view
import (
caos_errs "github.com/caos/zitadel/internal/errors"
"github.com/caos/zitadel/internal/view/repository"
"github.com/jinzhu/gorm"
@@ -23,6 +24,9 @@ func UserSessionByIDs(db *gorm.DB, table, agentID, userID string) (*model.UserSe
}
query := repository.PrepareGetByQuery(table, userAgentQuery, userQuery)
err := query(db, userSession)
if caos_errs.IsNotFound(err) {
return nil, caos_errs.ThrowNotFound(nil, "VIEW-NGBs1", "Errors.UserSession.NotFound")
}
return userSession, err
}

View File

@@ -39,6 +39,9 @@ func UserByLoginName(db *gorm.DB, table, loginName string) (*model.UserView, err
}
query := repository.PrepareGetByQuery(table, loginNameQuery)
err := query(db, user)
if caos_errs.IsNotFound(err) {
return nil, caos_errs.ThrowNotFound(nil, "VIEW-AD4qs", "Errors.User.NotFound")
}
return user, err
}