strongloop / loopback-example-passport

LoopBack example for facebook login
Other
185 stars 134 forks source link

local strategy #7

Closed eliorcohen closed 8 years ago

eliorcohen commented 10 years ago

hey, first of all, great work with the framework, like the road you going :)

i am trying to set up the local strategy to work along side with the social logins,

after probing the code , i have set up the config as follow:

    "local": {
        "module": "passport-local",
        "provider": "local",
        "successRedirect": "/auth/account",
        "session": true
    }

then i tested it by adding a user to the db with the explorer... ( using the mongodb connector). i have noticed that i have two "users" models differing by capital letters. ("Users", "users") but they both points to the same api url ("/api/Users").

i have tried to manually post the the "/api/users" path, but it's seems to be connected to the "User" model and not the "user" model...

i have also try to specify the collection name on the "users" model as follow:

"options": {
        "mongodb": {
            "collection": "users"
        }
    },

but it has no affect on the result, and the data keep's on going into the "Users" collection in the DB.

the social login work fine, tested it with facebook login but the data is located on the "users" collection...

i don't really understand the reason for re-create the user model (and others) with lower casing and i guess i will need to dive in to figure the overall solution..

is there a fix for this coming soon? is there an architectural problem that i should be aware of?

thx, elior

raymondfeng commented 10 years ago

Are you on loopback 1.x or 2.x?

eliorcohen commented 10 years ago

loopback 2.1.3

raymondfeng commented 10 years ago

I just pushed some fixes into https://github.com/strongloop/loopback-example-passport. Can you try again? Some of the code were messed up during the migration from 1.x to 2.x by one of our community members.

Alexandre-io commented 10 years ago

Hi,

Did you forgot to include the bodyParser to support the LocalStrategy ?

// server.js
var bodyParser = require('body-parser');
//...
app.use(bodyParser.json()); // to support JSON-encoded bodies
app.use(bodyParser.urlencoded({
    extended: true
})); // to support URL-encoded bodies

This solve my issue: 400 Bad Request

loay commented 8 years ago

Hi @eliorcohen Is this issue fixed after the fixes mentioned by Raymond, or still having problems? Thanks.

eliorcohen commented 8 years ago

If i remember currectly, it did fix the probleam.