Skip to content

Commit

Permalink
admin dashboard button link
Browse files Browse the repository at this point in the history
  • Loading branch information
singharaj-usai committed Oct 14, 2024
1 parent 1616010 commit 5ea15ef
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 4 deletions.
6 changes: 6 additions & 0 deletions client/html/components/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@
<li class="visible-xs">
<a href="/my/create"><i class="bi bi-tools"></i> Create</a>
</li>
<li class="visible-xs admin-dashboard-link" style="display: none;">
<a href="/admin/dashboard"><i class="bi bi-speedometer2"></i> Admin Dashboard</a>
</li>
</ul>

<div class="nav navbar-nav navbar-right">
Expand Down Expand Up @@ -173,6 +176,9 @@
<li>
<a href="/my/create"><i class="bi bi-tools"></i> Create</a>
</li>
<li class="admin-dashboard-link" style="display: none;">
<a href="/admin/dashboard"><i class="bi bi-speedometer2"></i> Admin Dashboard</a>
</li>
</ul>
</div>
</nav>
Expand Down
3 changes: 2 additions & 1 deletion client/html/pages/admin/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li><a href="#" id="logout-btn">Logout</a></li>
<li><a href="/" id="go-back-btn"><i class="bi bi-arrow-left"></i> Back to Website</a></li>
<!-- <li><a href="#" id="logout-btn">Logout</a></li> -->
</ul>
</div>
</div>
Expand Down
19 changes: 16 additions & 3 deletions client/js/admin/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,20 @@ function loadOverview() {
<div class="panel-body">
<p class="lead">Select a section from the sidebar or click on a panel below to manage different aspects of the website.</p>
<div class="row">
<div class="col-md-4">
<div class="col-md-3">
<div class="panel panel-primary clickable-panel" data-section="assets">
<div class="panel-heading">
<h4 class="panel-title"><i class="fa fa-comments"></i> Assets</h4>
</div>
<div class="panel-body">
<p>View and manage assets.</p>
<button class="btn btn-primary btn-block">
<span class="underline">Go to Assets</span>
</button>
</div>
</div>
</div>
<div class="col-md-3">
<div class="panel panel-info clickable-panel" data-section="forum-posts">
<div class="panel-heading">
<h4 class="panel-title"><i class="fa fa-comments"></i> Forum Posts</h4>
Expand All @@ -70,7 +83,7 @@ function loadOverview() {
</div>
</div>
</div>
<div class="col-md-4">
<div class="col-md-3">
<div class="panel panel-success clickable-panel" data-section="users">
<div class="panel-heading">
<h4 class="panel-title"><i class="fa fa-users"></i> Users</h4>
Expand All @@ -83,7 +96,7 @@ function loadOverview() {
</div>
</div>
</div>
<div class="col-md-4">
<div class="col-md-3">
<div class="panel panel-warning clickable-panel" data-section="games">
<div class="panel-heading">
<h4 class="panel-title"><i class="fa fa-gamepad"></i> Games</h4>
Expand Down
13 changes: 13 additions & 0 deletions client/js/auth/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,17 @@ const App = {
html: true,
container: 'body',
});

if (response.isAdmin) {
$('.admin-dashboard-link').show();
} else {
$('.admin-dashboard-link').hide();
}


// Show mobile user submenu for all authenticated users
$('#mobile-user-submenu').show();

},
error: (xhr, status, error) => {
console.error('Error fetching user info:', error);
Expand All @@ -306,6 +317,8 @@ const App = {
<a href="/register" class="btn btn-sm btn-default ml-2 navbar-btn">Register</a>
`);
$('#user-submenu').hide();
$('#mobile-user-submenu').hide();
$('.admin-dashboard-link').hide();
}
if (typeof updateAnnouncementPosition === 'function') {
updateAnnouncementPosition();
Expand Down
6 changes: 6 additions & 0 deletions server/functions/api/routes/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,12 @@ router.post('/login', flexibleCsrfProtection, authLimiter, async (req, res) => {
});
}

if (user.isBanned) {
return res.status(403).json({
message: 'Your account is banned. Please contact the administrator for more information.',
});
}

const isValidPassword = await bcrypt.compare(password, user.password);
if (!isValidPassword) {
user.loginAttempts += 1;
Expand Down
1 change: 1 addition & 0 deletions server/functions/api/routes/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ router.get('/user-info', authenticateToken, async (req, res) => {
username: user.username,
currency: user.currency,
lastCurrencyClaimDate: user.lastCurrencyClaimDate,
isAdmin: user.isAdmin,
});
} catch (error) {
console.error('Error fetching user info:', error);
Expand Down

0 comments on commit 5ea15ef

Please sign in to comment.