mirror of
https://github.com/zitadel/zitadel.git
synced 2025-06-13 07:12:32 +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
|
package view
|
||||||
|
|
||||||
import (
|
import (
|
||||||
global_model "github.com/caos/zitadel/internal/model"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/jinzhu/gorm"
|
|
||||||
"github.com/lib/pq"
|
|
||||||
|
|
||||||
"github.com/caos/zitadel/internal/errors"
|
"github.com/caos/zitadel/internal/errors"
|
||||||
|
global_model "github.com/caos/zitadel/internal/model"
|
||||||
token_model "github.com/caos/zitadel/internal/token/model"
|
token_model "github.com/caos/zitadel/internal/token/model"
|
||||||
"github.com/caos/zitadel/internal/token/repository/view/model"
|
"github.com/caos/zitadel/internal/token/repository/view/model"
|
||||||
"github.com/caos/zitadel/internal/view/repository"
|
"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) {
|
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)
|
query := repository.PrepareGetByKey(table, model.TokenSearchKey(token_model.TokenSearchKeyTokenID), tokenID)
|
||||||
err := query(db, token)
|
err := query(db, token)
|
||||||
if errors.IsNotFound(err) {
|
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
|
return token, err
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,7 @@ const (
|
|||||||
UserGrantSearchKeyGrantID
|
UserGrantSearchKeyGrantID
|
||||||
UserGrantSearchKeyOrgName
|
UserGrantSearchKeyOrgName
|
||||||
UserGrantSearchKeyRoleKey
|
UserGrantSearchKeyRoleKey
|
||||||
|
UserGrantSearchKeyID
|
||||||
)
|
)
|
||||||
|
|
||||||
type UserGrantSearchQuery struct {
|
type UserGrantSearchQuery struct {
|
||||||
|
@ -65,6 +65,8 @@ func (key UserGrantSearchKey) ToColumnName() string {
|
|||||||
return UserGrantKeyOrgName
|
return UserGrantKeyOrgName
|
||||||
case grant_model.UserGrantSearchKeyRoleKey:
|
case grant_model.UserGrantSearchKeyRoleKey:
|
||||||
return UserGrantKeyRole
|
return UserGrantKeyRole
|
||||||
|
case grant_model.UserGrantSearchKeyID:
|
||||||
|
return UserGrantKeyID
|
||||||
default:
|
default:
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
@ -10,13 +10,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func UserGrantByID(db *gorm.DB, table, grantID string) (*model.UserGrantView, error) {
|
func UserGrantByID(db *gorm.DB, table, grantID string) (*model.UserGrantView, error) {
|
||||||
user := new(model.UserGrantView)
|
grant := new(model.UserGrantView)
|
||||||
query := repository.PrepareGetByKey(table, model.UserGrantSearchKey(grant_model.UserGrantSearchKeyGrantID), grantID)
|
query := repository.PrepareGetByKey(table, model.UserGrantSearchKey(grant_model.UserGrantSearchKeyID), grantID)
|
||||||
err := query(db, user)
|
err := query(db, grant)
|
||||||
if caos_errs.IsNotFound(err) {
|
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) {
|
func UserGrantByIDs(db *gorm.DB, table, resourceOwnerID, projectID, userID string) (*model.UserGrantView, error) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user