mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-15 01:57:41 +00:00
feat(auth): My user changes (#318)
* fix: project by id loads project from view and from eventstore * fix: correct search key for role * feat(auth): my user changes * fix: improve error handling in change converters * fix: log-id
This commit is contained in:
@@ -14,7 +14,7 @@ type UserGrantCache struct {
|
||||
|
||||
func StartCache(conf *config.CacheConfig) (*UserGrantCache, error) {
|
||||
userGrantCache, err := conf.Config.NewCache()
|
||||
logging.Log("EVENT-vDneN").OnError(err).Panic("unable to create user cache")
|
||||
logging.Log("EVENT-8EhUZ").OnError(err).Panic("unable to create user grant cache")
|
||||
|
||||
return &UserGrantCache{userGrantCache: userGrantCache}, nil
|
||||
}
|
||||
@@ -22,13 +22,13 @@ func StartCache(conf *config.CacheConfig) (*UserGrantCache, error) {
|
||||
func (c *UserGrantCache) getUserGrant(ID string) *model.UserGrant {
|
||||
user := &model.UserGrant{ObjectRoot: models.ObjectRoot{AggregateID: ID}}
|
||||
err := c.userGrantCache.Get(ID, user)
|
||||
logging.Log("EVENT-4eTZh").OnError(err).Debug("error in getting cache")
|
||||
|
||||
logging.Log("EVENT-QAd7T").OnError(err).Debug("error in getting cache")
|
||||
|
||||
return user
|
||||
}
|
||||
|
||||
func (c *UserGrantCache) cacheUserGrant(grant *model.UserGrant) {
|
||||
err := c.userGrantCache.Set(grant.AggregateID, grant)
|
||||
|
||||
logging.Log("EVENT-ThnBb").OnError(err).Debug("error in setting project cache")
|
||||
logging.Log("EVENT-w2KNQ").OnError(err).Debug("error in setting user grant cache")
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@ package eventsourcing
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/caos/zitadel/internal/api/auth"
|
||||
"github.com/caos/zitadel/internal/errors"
|
||||
es_models "github.com/caos/zitadel/internal/eventstore/models"
|
||||
@@ -209,10 +210,7 @@ func addUserGrantValidation(resourceOwner string, grant *model.UserGrant) func(.
|
||||
if !existsUser {
|
||||
return errors.ThrowPreconditionFailed(nil, "EVENT-Sl8uS", "user doesn't exist")
|
||||
}
|
||||
if err := checkProjectConditions(resourceOwner, grant, project); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return checkProjectConditions(resourceOwner, grant, project)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user