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"
global_model "github.com/caos/zitadel/internal/model"
grant_model "github.com/caos/zitadel/internal/usergrant/model"
"github.com/caos/zitadel/internal/usergrant/repository/view/model"
@@ -12,6 +13,9 @@ func UserGrantByID(db *gorm.DB, table, grantID string) (*model.UserGrantView, er
user := new(model.UserGrantView)
query := repository.PrepareGetByKey(table, model.UserGrantSearchKey(grant_model.UserGrantSearchKeyGrantID), grantID)
err := query(db, user)
if caos_errs.IsNotFound(err) {
return nil, caos_errs.ThrowNotFound(nil, "VIEW-Nqwf1", "Errors.Token.NotFound")
}
return user, err
}
@@ -23,6 +27,9 @@ func UserGrantByIDs(db *gorm.DB, table, resourceOwnerID, projectID, userID strin
userIDQuery := model.UserGrantSearchQuery{Key: grant_model.UserGrantSearchKeyUserID, Value: userID, Method: global_model.SearchMethodEquals}
query := repository.PrepareGetByQuery(table, resourceOwnerIDQuery, projectIDQuery, userIDQuery)
err := query(db, user)
if caos_errs.IsNotFound(err) {
return nil, caos_errs.ThrowNotFound(nil, "VIEW-Q1tq2", "Errors.UserGrant.NotFound")
}
return user, err
}