Hi,
You might need concept of a "User" instead of just Student / Teacher.
passport.use(new BearerStrategy(
function(token, done) {
User.findOne({ token: token }, function (err, user) {
if (err) { return done(err); }
if (!user) { return done(null, false); }
return done(null, user, { scope: 'all' });
});
}
));
Linking which user has which role is then up to you.
You could add a "type" or "role" property to your User obejcts or create a
join table *a la* SQL
Cheers,
On Wed, Jan 7, 2015 at 2:07 PM, Sachin Rajput <[email protected]>
wrote:
> Hi,
>
> I am using passport js bearer strategy for session authentication.
>
> passport.use(new BearerStrategy(
> function(token, done) {
> Student.findOne({ token: token }, function (err, student) {
> if (err) { return done(err); }
> if (!student) { return done(null, false); }
> return done(null, student, { scope: 'all' });
> });
> }
> ));
>
>
> which get fire whenever a request comes having '/secure' prefix.
>
>
> router.all('/secure/*',passport.authenticate('bearer', { session: false
> }),function(req,res,next){
> next();
> });
>
>
> but this authentication is done only for students. Suppose if there is
> teachers also so how will I do the same?
>
> --
> Job board: http://jobs.nodejs.org/
> New group rules:
> https://gist.github.com/othiym23/9886289#file-moderation-policy-md
> Old group rules:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> ---
> You received this message because you are subscribed to the Google Groups
> "nodejs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/nodejs/635ae1b8-aefb-4a29-8116-06c75ecfa240%40googlegroups.com
> <https://groups.google.com/d/msgid/nodejs/635ae1b8-aefb-4a29-8116-06c75ecfa240%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
Adrien Risser,
Freelance Node.js Consultant
M. +33 6 59 60 32 58
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/CAKGrCFghH1AwrE3xS_BHndbyPoAHa2bL21h4v4Woy6TdAtyJTw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.