From 2c4c6cb7fe868229ba3c3a5eddc80d5581574b19 Mon Sep 17 00:00:00 2001 From: mo khan Date: Wed, 30 Jul 2025 11:52:04 -0600 Subject: fix: return a global id for an anonymous user --- app/db/authorization.go | 9 --------- app/domain/user.go | 4 ++++ 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/app/db/authorization.go b/app/db/authorization.go index 3041f51..ec8e47b 100644 --- a/app/db/authorization.go +++ b/app/db/authorization.go @@ -108,14 +108,5 @@ func (r *authorization[T]) Save(ctx context.Context, item T) error { func (r *authorization[T]) subjectFrom(ctx context.Context) *v1.SubjectReference { currentUser := cfg.CurrentUser.From(ctx) - if currentUser == nil { - return &v1.SubjectReference{ - Object: &v1.ObjectReference{ - ObjectType: "user", - ObjectId: "*", - }, - } - } - return currentUser.ToSubjectReference() } diff --git a/app/domain/user.go b/app/domain/user.go index 198fafc..97bacdd 100644 --- a/app/domain/user.go +++ b/app/domain/user.go @@ -2,6 +2,7 @@ package domain import ( v1 "github.com/authzed/authzed-go/proto/authzed/api/v1" + "github.com/xlgmokha/x/pkg/x" ) type User struct { @@ -33,6 +34,9 @@ func (self *User) Sparkle(sparklee string, reason string) *Sparkle { } func (self *User) ToGID() GlobalID { + if x.IsZero(self.Username) { + return GlobalID("gid://sparkle/User/*") + } return GlobalID("gid://sparkle/User/" + self.Username) } -- cgit v1.2.3