Closed kahurangitama closed 8 years ago
Hey, sorry for not answering immediately. I'll take a look into it these days.
Sorry for disturbing, but it was my fault. For anyone who run into the same problem: double check your mongoose Schema, and rerun the server (it was my problem, I install npm, add field to existing user with MongoChef, but haven't update the Schema);
It should looks like this:
role: { type: String, default: 'member', enum: ['admin', 'moderator', 'member'] }
Hi there! I using PassportJS to authenticate users on my site. My routes looks like:
/routes/songs.js:
this is the only place where I use permission. Also I created a field named 'role' in my User schema. Then I debugged my app and observe that at this point:
req.user is undefined but console.log(req.session.passport) returns me:
it mean that user is authorized and there is a record in session, but req.user is undefined; my suggestion is that permission checks req.user before it actually filled by passport.deserializeUser()
How do you use permission with Passportjs?
Thanks in advance!