fix: User grant id key (#731)

* fix: log id and error message

* fix: user grant by id correct search field
This commit is contained in:
Silvan
2020-09-11 14:51:50 +02:00
committed by GitHub
parent 4926509de0
commit c37d55b069
4 changed files with 12 additions and 10 deletions

View File

@@ -48,6 +48,7 @@ const (
UserGrantSearchKeyGrantID
UserGrantSearchKeyOrgName
UserGrantSearchKeyRoleKey
UserGrantSearchKeyID
)
type UserGrantSearchQuery struct {

View File

@@ -65,6 +65,8 @@ func (key UserGrantSearchKey) ToColumnName() string {
return UserGrantKeyOrgName
case grant_model.UserGrantSearchKeyRoleKey:
return UserGrantKeyRole
case grant_model.UserGrantSearchKeyID:
return UserGrantKeyID
default:
return ""
}

View File

@@ -10,13 +10,13 @@ import (
)
func UserGrantByID(db *gorm.DB, table, grantID string) (*model.UserGrantView, error) {
user := new(model.UserGrantView)
query := repository.PrepareGetByKey(table, model.UserGrantSearchKey(grant_model.UserGrantSearchKeyGrantID), grantID)
err := query(db, user)
grant := new(model.UserGrantView)
query := repository.PrepareGetByKey(table, model.UserGrantSearchKey(grant_model.UserGrantSearchKeyID), grantID)
err := query(db, grant)
if caos_errs.IsNotFound(err) {
return nil, caos_errs.ThrowNotFound(nil, "VIEW-Nqwf1", "Errors.Token.NotFound")
return nil, caos_errs.ThrowNotFound(nil, "VIEW-Nqwf1", "Errors.UserGrant.NotFound")
}
return user, err
return grant, err
}
func UserGrantByIDs(db *gorm.DB, table, resourceOwnerID, projectID, userID string) (*model.UserGrantView, error) {