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

@@ -3,12 +3,11 @@ package bigcache
import (
"bytes"
"encoding/gob"
"github.com/caos/logging"
"reflect"
"github.com/caos/zitadel/internal/errors"
a_cache "github.com/allegro/bigcache"
"github.com/caos/logging"
"github.com/caos/zitadel/internal/errors"
)
type Bigcache struct {
@@ -30,19 +29,19 @@ func NewBigcache(c *Config) (*Bigcache, error) {
func (c *Bigcache) Set(key string, object interface{}) error {
if key == "" || reflect.ValueOf(object).IsNil() {
return errors.ThrowInvalidArgument(nil, "FASTC-du73s", "key or value should not be empty")
return errors.ThrowInvalidArgument(nil, "BIGCA-du73s", "key or value should not be empty")
}
var b bytes.Buffer
enc := gob.NewEncoder(&b)
if err := enc.Encode(object); err != nil {
return errors.ThrowInvalidArgument(err, "FASTC-RUyxI", "unable to encode object")
return errors.ThrowInvalidArgument(err, "BIGCA-RUyxI", "unable to encode object")
}
return c.cache.Set(key, b.Bytes())
}
func (c *Bigcache) Get(key string, ptrToObject interface{}) error {
if key == "" || reflect.ValueOf(ptrToObject).IsNil() {
return errors.ThrowInvalidArgument(nil, "FASTC-dksoe", "key or value should not be empty")
return errors.ThrowInvalidArgument(nil, "BIGCA-dksoe", "key or value should not be empty")
}
value, err := c.cache.Get(key)
if err == a_cache.ErrEntryNotFound {
@@ -61,7 +60,7 @@ func (c *Bigcache) Get(key string, ptrToObject interface{}) error {
func (c *Bigcache) Delete(key string) error {
if key == "" {
return errors.ThrowInvalidArgument(nil, "FASTC-clsi2", "key should not be empty")
return errors.ThrowInvalidArgument(nil, "BIGCA-clsi2", "key should not be empty")
}
return c.cache.Delete(key)
}