Skip to content

Commit 8f03f5f

Browse files
committed
bypassed subscription for admin
1 parent e3aabb4 commit 8f03f5f

File tree

4 files changed

+17
-63
lines changed

4 files changed

+17
-63
lines changed

pnpm-lock.yaml

Lines changed: 0 additions & 61 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/js/views/dashboard.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,15 @@ function initDashboard() {
4545
}
4646

4747
// Check if user has access
48-
if (!hasAccess(user)) {
48+
if(user.is_admin === true) {
49+
50+
} else {
51+
if (!hasAccess(user)) {
4952
// Redirect to subscription page
5053
alert('You need an active subscription to access the dashboard.');
5154
window.router.navigate('/subscription');
5255
return;
56+
}
5357
}
5458

5559
// Set up tab switching

src/middleware/auth-middleware.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ export async function authMiddleware(c, next) {
111111
}, 401);
112112
}
113113

114+
// Ensure is_admin is always present in user object
115+
if (typeof user.is_admin === 'undefined') {
116+
user.is_admin = false;
117+
}
118+
114119
// Set user in context for later use
115120
c.set('user', user);
116121

src/middleware/subscription-check.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ export async function subscriptionCheck(c, next) {
1919
if (freeEndpoints.includes(c.req.path)) {
2020
return next();
2121
}
22-
22+
23+
// Bypass subscription check for admin users
24+
const user = c.get('user');
25+
if (user && user.is_admin) {
26+
return next();
27+
}
28+
2329
// Get API key from header
2430
const apiKey = c.req.header('X-API-Key');
2531

0 commit comments

Comments
 (0)