feat: allow premium+ users to manage costs
Build & Push Docker Image / build (push) Successful in 2m19s
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:
@@ -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,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user