Skip to content

Commit

Permalink
Merge pull request #27 from Vishvaas06/main
Browse files Browse the repository at this point in the history
Changes
  • Loading branch information
Faf4a authored Jun 15, 2024
2 parents ed7bf20 + beedeb0 commit 7ebbc85
Show file tree
Hide file tree
Showing 8 changed files with 295 additions and 332 deletions.
9 changes: 4 additions & 5 deletions src/helpers/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ module.exports = (dashboard) => {
const router = express.Router();
const render = (filePath, auth = false, admin = false) => {
return async (req, res) => {
if (auth && !req.isAuthenticated()) return res.redirect("/login");
if (auth && !req.isAuthenticated()) return res.redirect("/auth/login");

if (admin && !req.isAuthenticated()) return res.redirect("/login");
if (admin && !req.isAuthenticated()) return res.redirect("/auth/login");

const isAllowed = await getDashboardAdmins(req.user?.id)

Expand Down Expand Up @@ -75,7 +75,7 @@ module.exports = (dashboard) => {
if (req.isAuthenticated()) {
return next();
}
res.redirect("/login");
res.redirect("/auth/login");
};

async function getDashboardAdmins(user) {
Expand Down Expand Up @@ -117,14 +117,13 @@ module.exports = (dashboard) => {
saveUninitialized: true
})
);

router.use(passport.initialize());
router.use(passport.session());
router.use("/auth", require("../helpers/routes/Auth.js"));
router.use("/api", routes(dashboard));

router.get("/", render("../public/main/index.html"));
router.get("/login", render("../public/auth/login.html"));
router.get("/commands", render("../public/main/commands.html"));
router.get("/dash", render("../public/main/dash.html", true));
router.get("/status", render("../public/main/status.html"));
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/routes/Data.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const router = express.Router();

const ensureAuthenticated = (req, res, next) => {
if (req.isAuthenticated()) return next();
res.redirect("/login");
res.redirect("/auth/login");
};

router.use(express.json());
Expand Down
63 changes: 57 additions & 6 deletions src/public/admin/admin.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,28 @@
}
body {
margin: 0;
cursor: none;
font-family: "DM Sans", sans-serif;
background: var(--background);
background-size: cover;
color: var(--text);
}
.custom-cursor {
position: absolute;
width: 0;
height: 0;
border-left: 7px solid transparent;
border-right: 7px solid transparent;
border-bottom: 15px solid var(--text);
transform-origin: center;
pointer-events: none;
transition: transform 0.1s ease-out, border-color 0.1s ease-out;
z-index: 10000;
}

a:hover{
cursor: none !important;
}
.navbar {
user-select: none;
overflow: hidden;
Expand All @@ -130,6 +147,7 @@
border-bottom: 1px solid var(--border);
z-index: 5;
}

.navbar a {
user-select: none;
z-index: 5;
Expand All @@ -141,12 +159,31 @@
align-self: flex-end !important;
vertical-align: middle !important;
text-decoration: none;
position: relative !important;
}

.navbar a::after{
bottom: 0;
margin: -1px;
content: "";
height: 1px;
left: 50%;
position: absolute;
background: var(--text);
transition: width 0.3s ease 0s, left 0.3s ease 0s;
width: 0;
}
.navbar a:hover,
.navbar a:active {
border-bottom: 1px solid var(--text);

.navbar a:hover, .navbar a:active{
color: var(--text);
}

.navbar a:hover::after,
.navbar a:active::after {
width: 100%;
left: 0;
}

.icons-container {
display: flex;
align-items: center;
Expand Down Expand Up @@ -415,7 +452,6 @@
display: table;
}
#navbar-data {
cursor: pointer;
text-wrap: nowrap;
}
.rounded-icon {
Expand Down Expand Up @@ -503,6 +539,9 @@
.button-container button {
width: calc(50% - 10px);
}
.button-container button:hover {
cursor: none;
}
.button-container .full-width {
width: 100%;
clear: both;
Expand Down Expand Up @@ -791,6 +830,7 @@
</style>
</head>
<body data-theme="light">
<div class="custom-cursor" id="cursor"></div>
<div class="dim-overlay" onclick="toggleNavbar()">
<div id="navbar-links" class="navbar-mobile">
<% global.navbar.forEach(x => { %> <% if (x.to) { %>
Expand All @@ -809,7 +849,7 @@
</div>
</a>
<% } else { %>
<a href="/login" style="margin-top: 35px; display: flex; align-items: center" class="mlink icon">
<a href="/auth/login" style="margin-top: 35px; display: flex; align-items: center" class="mlink icon">
<i class="material-icons" style="margin-right: 15px">login</i>
<span>Login</span>
</a>
Expand Down Expand Up @@ -842,7 +882,7 @@
<span class="hide">Logout</span>
</a>
<% } else { %>
<a href="/login" class="icon discord-login">
<a href="/auth/login" class="icon discord-login">
<i class="material-icons" style="margin-right: 5px">login</i>
<span>Login</span>
</a>
Expand Down Expand Up @@ -967,6 +1007,12 @@ <h1>Dashboard Admins</h1>
</div>
</div>
</div>
<footer>
<center>
<img src="https://github.com/aoijs/website/blob/master/assets/images/aoijs-logo.png?raw=true" style="user-select: none;width: 8%;"draggable="false">
</center>
</footer>

<script>
const sun = document.querySelector(".sun-icon");
const moon = document.querySelector(".moon-icon");
Expand Down Expand Up @@ -1315,6 +1361,11 @@ <h1>Dashboard Admins</h1>
toastr.success(`Removed '${userId}' as dashboard admin.`);
});
}
document.addEventListener('mousemove', function(e) {
var cursor = document.getElementById('cursor');
cursor.style.left = e.pageX + 'px';
cursor.style.top = e.pageY + 'px';
});
</script>
</body>
</html>
Loading

0 comments on commit 7ebbc85

Please sign in to comment.