Skip to content

Commit 22f2acb

Browse files
authored
Upgrade Session to Project even without account (#28)
1 parent 56e5123 commit 22f2acb

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

middleware.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ func Session(cfg Options) func(next http.Handler) http.Handler {
185185

186186
if user != nil {
187187
ctx = WithUser(ctx, user)
188-
189188
sessionType = proto.SessionType_User
190189
if isAdmin {
191190
sessionType = proto.SessionType_Admin
@@ -196,11 +195,11 @@ func Session(cfg Options) func(next http.Handler) http.Handler {
196195
if adminClaim {
197196
sessionType = proto.SessionType_Admin
198197
}
198+
}
199199

200-
if projectClaim > 0 {
201-
ctx = WithProjectID(ctx, uint64(projectClaim))
202-
sessionType = proto.SessionType_Project
203-
}
200+
if projectClaim > 0 {
201+
ctx = WithProjectID(ctx, uint64(projectClaim))
202+
sessionType = max(sessionType, proto.SessionType_Project)
204203
}
205204
}
206205

0 commit comments

Comments
 (0)