mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 02:54:20 +00:00
remove pointer on ctxData
This commit is contained in:
parent
501d453822
commit
e5e39b3a6a
@ -2,7 +2,6 @@ package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/caos/logging"
|
||||
)
|
||||
@ -43,24 +42,15 @@ func VerifyTokenAndWriteCtxData(ctx context.Context, token, orgID string, t Toke
|
||||
projectID, err := t.GetProjectIDByClientID(ctx, clientID)
|
||||
logging.LogWithFields("AUTH-GfAoV", "clientID", clientID).OnError(err).Warn("could not read projectid by clientid")
|
||||
|
||||
return context.WithValue(ctx, CtxKeyData{}, &CtxData{UserID: userID, OrgID: orgID, ProjectID: projectID, AgentID: agentID}), nil
|
||||
return context.WithValue(ctx, CtxKeyData{}, CtxData{UserID: userID, OrgID: orgID, ProjectID: projectID, AgentID: agentID}), nil
|
||||
}
|
||||
|
||||
func GetCtxData(ctx context.Context) CtxData {
|
||||
if data := ctx.Value(CtxKeyData{}); data != nil {
|
||||
ctxData, ok := data.(*CtxData)
|
||||
if ok {
|
||||
return *ctxData
|
||||
}
|
||||
time.Now()
|
||||
}
|
||||
return CtxData{}
|
||||
ctxData, _ := ctx.Value(CtxKeyData{}).(CtxData)
|
||||
return ctxData
|
||||
}
|
||||
|
||||
func GetPermissionsFromCtx(ctx context.Context) []string {
|
||||
if data := ctx.Value(CtxKeyPermissions{}); data != nil {
|
||||
ctxPermission, _ := data.([]string)
|
||||
return ctxPermission
|
||||
}
|
||||
return nil
|
||||
ctxPermission, _ := ctx.Value(CtxKeyPermissions{}).([]string)
|
||||
return ctxPermission
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
func getTestCtx(userID, orgID string) context.Context {
|
||||
return context.WithValue(context.Background(), CtxKeyData{}, &CtxData{UserID: userID, OrgID: orgID})
|
||||
return context.WithValue(context.Background(), CtxKeyData{}, CtxData{UserID: userID, OrgID: orgID})
|
||||
}
|
||||
|
||||
type testVerifier struct {
|
||||
|
Loading…
Reference in New Issue
Block a user