Saturday, 6 May 2017

user authorization with equals() in javascript

i have made a blog in which if a user made a post only them can edit it. But now i want to make an admin that can edit and delete any post he wants

if(foundBlog.author.id.equals(req.user._id ||  foundBlog.author.username === 
"ADMIN")) {
            next();
        } else {
            res.redirect("back");
        }
       } 

But my code doesn't work.



via fanis theologiths

No comments:

Post a Comment