We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I was trying to run this code but it is giving this error. I tried to resolve it, but nothing worked.
const JwtStrategy = require("passport-jwt").Strategy; const ExtractJwt = require("passport-jwt").ExtractJwt; const Faculty = require("../models/Faculty"); const Student = require("../models/Student"); const Admin = require("../models/Admin");
const keys = require("./key");
const opts = {}; opts.jwtFromRequest = ExtractJwt.fromAuthHeaderAsBearerToken(); opts.secretOrKey = keys.secretOrKey;
module.exports = (passport) => { passport.use( new JwtStrategy(opts, async (jwt_payload, done) => { const faculty = await Student.findById(jwt_payload.id); const student = await Faculty.findById(jwt_payload.id); const admin = await Admin.findById(jwt_payload.id);
if (faculty) { return done(null, faculty); } else if (student) { return done(null, student); } else if (admin) { return done(null, admin); } else { console.log("Passport Error"); } }) );
};
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I was trying to run this code but it is giving this error. I tried to resolve it, but nothing worked.
const JwtStrategy = require("passport-jwt").Strategy;
const ExtractJwt = require("passport-jwt").ExtractJwt;
const Faculty = require("../models/Faculty");
const Student = require("../models/Student");
const Admin = require("../models/Admin");
const keys = require("./key");
const opts = {};
opts.jwtFromRequest = ExtractJwt.fromAuthHeaderAsBearerToken();
opts.secretOrKey = keys.secretOrKey;
module.exports = (passport) => {
passport.use(
new JwtStrategy(opts, async (jwt_payload, done) => {
const faculty = await Student.findById(jwt_payload.id);
const student = await Faculty.findById(jwt_payload.id);
const admin = await Admin.findById(jwt_payload.id);
};
The text was updated successfully, but these errors were encountered: