feat: add GetUser helper to auth middleware

This commit is contained in:
2026-04-06 19:20:54 +02:00
parent 2657f19993
commit 243f07dbb6

View File

@@ -80,3 +80,12 @@ func RequireGlobalAuth(next http.Handler) http.Handler {
next.ServeHTTP(w, r)
})
}
// GetUser returns the user from context, or nil if not logged in
func GetUser(ctx context.Context) *database.User {
user, ok := ctx.Value(UserContextKey).(*database.User)
if !ok {
return nil
}
return user
}