Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
Utilities: update passportReuse.js
Browse files Browse the repository at this point in the history
1. Add Admin Checking
  • Loading branch information
gamer-1478 committed Feb 11, 2022
1 parent f294b39 commit 0416ecd
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions utilities/passportReuse.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,23 @@ function checkAuthenticated(req, res, next) {
if (req.isAuthenticated()) {
return next();
}

res.redirect("/login");
}

function checkNotAuthenticated(req, res, next) {
if (req.isAuthenticated()) {
return res.redirect(`/dashboard`);
return res.redirect(`/profile`);
}
next();
}

module.exports = { checkAuthenticated, checkNotAuthenticated }
function checkAdmin(req, res, next) {
if (req.isAuthenticated() && req.user.admin === true) {
return next();
}

res.redirect("/profile");

}

module.exports = { checkAdmin, checkAuthenticated, checkNotAuthenticated }

0 comments on commit 0416ecd

Please sign in to comment.