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:
Silvan
2020-07-01 07:18:05 +02:00
committed by GitHub
parent 4f3631acbb
commit cf7a906023
20 changed files with 3370 additions and 3655 deletions

View File

@@ -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")
}

View File

@@ -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)
}
}