feat: allow premium+ users to manage costs
Build & Push Docker Image / build (push) Successful in 2m19s

- costs routes drop requireAdmin, keep auth + costs feature check
- useAuth exposes hasFeature(feature) based on entitlements
- tool-detail costs section gated by hasFeature('costs') instead of isAdmin
This commit is contained in:
opencode
2026-08-02 01:27:28 +02:00
parent 01c70085db
commit 6b8ca92c37
3 changed files with 24 additions and 16 deletions
+7
View File
@@ -22,6 +22,12 @@ export function useAuth() {
const isLocalMode = authMode?.mode === "local";
const tier = isAuthenticated ? user?.tier ?? "free" : "free";
function hasFeature(feature: string): boolean {
if (!isAuthenticated) return false;
if (user?.role === "admin") return true;
return !!user?.entitlements?.includes(feature);
}
function login(returnTo?: string) {
if (isLocalMode) {
const path = returnTo
@@ -47,6 +53,7 @@ export function useAuth() {
isAdmin,
isLocalMode,
tier,
hasFeature,
login,
logout,
};