Skip to content

Commit 213b650

Browse files
committed
added exception for admins
1 parent d0afe1e commit 213b650

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

public/js/route-helpers.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ export function createRoute(viewPath, options = {}) {
4747
if (userJson) {
4848
const user = JSON.parse(userJson);
4949
const hasActiveSubscription = user?.subscription?.status === 'active';
50+
const isAdmin = user?.isAdmin === true;
5051

51-
if (!hasActiveSubscription) {
52+
// Allow access for users with either an active subscription or admin privileges
53+
if (!hasActiveSubscription && !isAdmin) {
5254
console.log('Subscription required, redirecting to subscription page');
5355
alert('You need an active subscription to access this page.');
5456
return next('/subscription');

public/js/views/dashboard.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,14 @@ function initDashboard() {
3333
}
3434
}
3535

36-
// Verify subscription status
36+
// Verify subscription status or admin privileges
3737
const hasActiveSubscription = user &&
3838
user.subscription &&
3939
user.subscription.status === 'active';
40+
const isAdmin = user && user.isAdmin === true;
4041

41-
if (!hasActiveSubscription) {
42+
// Allow access for users with either an active subscription or admin privileges
43+
if (!hasActiveSubscription && !isAdmin) {
4244
// Redirect to subscription page
4345
alert('You need an active subscription to access the dashboard.');
4446
window.router.navigate('/subscription');

0 commit comments

Comments
 (0)