mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 02:54:20 +00:00
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:
parent
4926509de0
commit
c37d55b069
@ -1,16 +1,15 @@
|
||||
package view
|
||||
|
||||
import (
|
||||
global_model "github.com/caos/zitadel/internal/model"
|
||||
"time"
|
||||
|
||||
"github.com/jinzhu/gorm"
|
||||
"github.com/lib/pq"
|
||||
|
||||
"github.com/caos/zitadel/internal/errors"
|
||||
global_model "github.com/caos/zitadel/internal/model"
|
||||
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"
|
||||
"github.com/jinzhu/gorm"
|
||||
"github.com/lib/pq"
|
||||
)
|
||||
|
||||
func TokenByID(db *gorm.DB, table, tokenID string) (*model.Token, error) {
|
||||
@ -18,7 +17,7 @@ func TokenByID(db *gorm.DB, table, tokenID string) (*model.Token, error) {
|
||||
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 nil, errors.ThrowNotFound(nil, "VIEW-6ub3p", "Errors.Token.NotFound")
|
||||
}
|
||||
return token, err
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ const (
|
||||
UserGrantSearchKeyGrantID
|
||||
UserGrantSearchKeyOrgName
|
||||
UserGrantSearchKeyRoleKey
|
||||
UserGrantSearchKeyID
|
||||
)
|
||||
|
||||
type UserGrantSearchQuery struct {
|
||||
|
@ -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 ""
|
||||
}
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user