How do Allow only Admins to have access to the Admin page in AdminBro
? Nodejs
All that I want is for only Admins to have access to the adminBro
page, is there any specific method to get this done?
I did this in my app.js
file but it's not working
app.get("/admin", function (req, res, next) {
res.locals.login = req.user;
if (res.locals.login.roles == "admin") {
app.use("/admin", adminRouter);
} else {
res.redirect("/");
}
});