ycpatel813/trailpack-passport-auth

Problems with deserializeUser in sqlite

agustim opened this issue · 4 comments

I'm using your trailpack in my application, but using with sqlite. The problem is in this line https://github.com/ycpatel813/trailpack-passport-auth/blob/master/lib/passports.js#L137

app.orm.User.findOne({_id: id})

because you find element id in field _id. This is only work in mongodb or database like there.
I changed for:

app.orm.User.findOne({id: id})

and it works for me. I know this is not best solution, i think de best solution is ask to orm what is the field of identify but i don't know how to do that.

[Update]
Now I change for:

app.orm.User.findOne(id)

In sqlite it works, and I think this solution works in any database.

@agustim thanks to review and suggestion i appreciate you. I have created it only for mongodb and my custom use but if you want to use then i will update it 😄

I send a pull request, please check with mongodb (i did not check), but i think it works in mongodb too.

@agustim i have found one trailpack-passport.
https://github.com/jaumard/trailpack-passport/ this is improved version of passport if this full fill your requirement then check it and let me know.