I want to make some users be admins i heard i can do this if i add a class to a user but i don't know how here is my code. I want to have some information only be displayed to admins like edit buttons and delete buttons.
app.use(function(req, res, next){
res.locals.currentUser = req.user;
res.locals.error = req.flash("error");
res.locals.success = req.flash("success");
next();
});
//AUTH
app.get("/register", function(req, res){
res.render("register");
});
app.post("/register", function(req, res){
var newUser = new User({username: req.body.username, password:
req.body.password});
User.register(newUser, req.body.password, function(err, user){
if(err){
console.log(err);
req.flash("error", "You Can't Register");
return res.render("register");
}
passport.authenticate("local")(req, res, function(){
req.flash("success", "You Have Successfully Registered!");
online = online +1;
console.log("users that are online: " + online);
res.redirect("/blogs");
});
});
});
app.get("/login", function(req, res){
res.render("login");
});
// handling login logic
app.post("/login", passport.authenticate("local",
{
successRedirect: "/blogs",
failureRedirect: "/login"
}), function(req, res){
});
function loggedIn(req, res, next) {
if (req.user) {
online = online +1;
console.log("users that are online: " + online);
}
}
via fanis theologiths
No comments:
Post a Comment