asm-products/boxychat — pull request #5 by DevAlien (2014-11-16 02:25:16+00:00)
Title: 18 add passportjs

I've added a concept of "services" you can access them via Service.serviceName (Service is global) or app.services.serviceName. You can see an example of this on the file api/services/crypt.js.
I also changed all the BaseController res.json because it was throwing a warning, the ErrorCode was inverted.

I created a basic user model, using the crypt I hash the password before inserting it and added a function to check if the password is the same.

PassportJS is now integrated, at the moment I've integrated a local auth system with sessions but I don't know if it's the best approach and it is what we want to have later on.

To test it you could create a user and try to login with the right credentials and should have a 200 with success: true and try with a wrong password and should get a 500.

To create a user you could simply run the following:
`````
curl -H "Content-Type: application/json" -d '{"email":"email@email.com","password":"pass"}' http://localhost:3000/user
`````

and then try to login with:
`````
curl -H "Content-Type: application/json" -d '{"email":"email@email.com","password":"pass"}' http://localhost:3000/login
`````