-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
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
ReferenceError: User is not defined #37
Comments
Any updates on this? I'm getting the same. |
Turns out User.* is just an example of user code, it's not anything included by this module. |
yes, I am facing the same situation, what should I do? |
I have figured out what went wrong. 'User' is a something like database or a object mapper and is not provided by passport module. Actually, you don't need it. old:User.findOrCreate({ waId: profile.id }, function (err, user) { new:if (profile) { |
still it doesnt work!!!! |
Seems like User should be defined as a sequelize instance |
From both points we can see that the variable to require the model file should be used in find() method |
add this serializer if you are not getting the error - "Failed to serialize user into session" passport.serializeUser(function(user, done) { |
@raginiagrawal02 I have that and my code is not working. But, I also have the following: |
Nevermind, solved it! |
How did you solve it |
const User = require('../models/User') import this line and solve your error |
Hi guys,
I test the most simple :
passport.use(new WindowsStrategy({
integrated: true
}, function(profile, done){
User.findOrCreate({ waId: profile.id }, function (err, user) {
done(err, user);
});
}));
app.get('/windows',
passport.authenticate('WindowsAuthentication'),
function (req, res){
res.redirect('/foo/bar');
});
But I always get :
ReferenceError: User is not defined
at Strategy._verify (C:\inetpub\wwwroot\auth\server.js:48:5)
at Strategy.authenticate (C:\inetpub\wwwroot\auth\node_modules\passport-windowsauth\lib\strategy.js:163:12)
at attempt (C:\inetpub\wwwroot\auth\node_modules\passport\lib\middleware\authenticate.js:348:16)
at authenticate (C:\inetpub\wwwroot\auth\node_modules\passport\lib\middleware\authenticate.js:349:7)
at Layer.handle as handle_request
at next (C:\inetpub\wwwroot\auth\node_modules\express\lib\router\route.js:131:13)
at Route.dispatch (C:\inetpub\wwwroot\auth\node_modules\express\lib\router\route.js:112:3)
at Layer.handle as handle_request
at C:\inetpub\wwwroot\auth\node_modules\express\lib\router\index.js:277:22
at Function.process_params (C:\inetpub\wwwroot\auth\node_modules\express\lib\router\index.js:330:12)
at next (C:\inetpub\wwwroot\auth\node_modules\express\lib\router\index.js:271:10)
at SessionStrategy.strategy.pass (C:\inetpub\wwwroot\auth\node_modules\passport\lib\middleware\authenticate.js:325:9)
at SessionStrategy.authenticate (C:\inetpub\wwwroot\auth\node_modules\passport\lib\strategies\session.js:71:10)
at attempt (C:\inetpub\wwwroot\auth\node_modules\passport\lib\middleware\authenticate.js:348:16)
at authenticate (C:\inetpub\wwwroot\auth\node_modules\passport\lib\middleware\authenticate.js:349:7)
at Layer.handle as handle_request
Any idea ?
The text was updated successfully, but these errors were encountered: