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,7 +1,6 @@
package view
import (
"github.com/caos/zitadel/internal/view/repository"
"time"
"github.com/jinzhu/gorm"
@@ -10,12 +9,16 @@ import (
"github.com/caos/zitadel/internal/errors"
token_model "github.com/caos/zitadel/internal/token/model"
"github.com/caos/zitadel/internal/token/repository/view/model"
"github.com/caos/zitadel/internal/view/repository"
)
func TokenByID(db *gorm.DB, table, tokenID string) (*model.Token, error) {
token := new(model.Token)
query := repository.PrepareGetByKey(table, model.TokenSearchKey(token_model.TokenSearchKeyTokenID), tokenID)
err := query(db, token)
if errors.IsNotFound(err) {
return nil, errors.ThrowNotFound(nil, "VIEW-Nqwf1", "Errors.Token.NotFound")
}
return token, err
}