feat: add GetUser helper to auth middleware
This commit is contained in:
@@ -80,3 +80,12 @@ func RequireGlobalAuth(next http.Handler) http.Handler {
|
|||||||
next.ServeHTTP(w, r)
|
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
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user