jaredhanson / passport

Simple, unobtrusive authentication for Node.js.
https://www.passportjs.org?utm_source=github&utm_medium=referral&utm_campaign=passport&utm_content=about
MIT License
22.92k stars 1.24k forks source link

LocalStrategy callback does not execute my codes #415

Open hahamed opened 9 years ago

hahamed commented 9 years ago

Hello I used any example of passport (simple tutorials) exist on internet. I codes many ways of passport. But all of my codes in LocalStrategy callback not execute. node.exe is 0.12.7.0 express 4.11.0 and latest passport.

in this example see:

passport.use(new LocalStrategy( function (username, password, done) { console.log(1111); ..... return done(null, user); } ));

console.log(1111) not log and continuous codes does not execute.

thanks for reply

maleeb commented 9 years ago

me too, same problem, i use:

.post('/api/v1/signin', function(req, res) {
    console.log("TEST POST SIGNIN");
    Passport.use(new LocalStrategy(
           function(username, password, done) {
               console.log("TEST PASSPORT");

The first output "TEST POST SIGNIN" works, but after Passport usage, i dont see the output "TEST PASSPORT" on the server console. I call the post route with "postman" -> Body(x-www-form-urlencode) with key´s (username, password). Nothing happened.

i search the inet for solution bot nothing helps..

an idea?

Nodejs = 4.1.1 Express = 4.13.3 express-session = 1.11.3 cookie-parser = 1.4.0 passport = 0.3.0 passport-local = 1.0.0

thx

slamuu commented 9 years ago

I had this issue as well, I had to use application/json instead of application/javascript in order to have the strategy execute

maleeb commented 9 years ago

you man as header - Content-Type in postman? if yes, it dont work for me.

maleeb commented 9 years ago

ok i found the solution

first i have to define:

Passport.use(new LocalStrategy(
    function(username, password, done) {
        console.log("TESTTTTTT");
...

than i can call it with:

.post('/api/v1/signin', Passport.authenticate('local'), function(req, res) {
...

it works now but hope thats the right way?