From 05b3e77d5c9526f3b4b3ea4b28ba8089c4886082 Mon Sep 17 00:00:00 2001 From: Alex Guerrieri Date: Tue, 19 Nov 2024 22:34:27 +0100 Subject: [PATCH] Upgrade Session to Project even without account --- middleware.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/middleware.go b/middleware.go index e8e6452..3c787da 100644 --- a/middleware.go +++ b/middleware.go @@ -185,7 +185,6 @@ func Session(cfg Options) func(next http.Handler) http.Handler { if user != nil { ctx = WithUser(ctx, user) - sessionType = proto.SessionType_User if isAdmin { sessionType = proto.SessionType_Admin @@ -196,11 +195,11 @@ func Session(cfg Options) func(next http.Handler) http.Handler { if adminClaim { sessionType = proto.SessionType_Admin } + } - if projectClaim > 0 { - ctx = WithProjectID(ctx, uint64(projectClaim)) - sessionType = proto.SessionType_Project - } + if projectClaim > 0 { + ctx = WithProjectID(ctx, uint64(projectClaim)) + sessionType = max(sessionType, proto.SessionType_Project) } }