strongloop/loopback-component-passport — pull request #24 by pandaiolo (2014-09-22 16:21:28+00:00)
Title: Migrate component to 2.x way of storing models (JSON+JS)

This PR aims to reduce the amount of user confiuration needed to use the component, and evolves toward loopback 2.0 way of dealing with models - each model in a json+js file

Main changes :

* Split of user-identity and user-credential models
* Model base config moved into json file
* Added better handling of custom user model by auto adding relations

Usage :

* Add `../node_modules/loopback-component-passport/lib/models` in `model-config.json` file in `_meta`
* Add any subset of the models you need between `UserIdentity`, `UserCredential` and `ApplicationCredential` in model-config.json` so they are connected to the proper datasource
* Should work with base User class or custom model
* No need to redefine `UserIdentity`, etc in `common/models`

Example `server/model-config.js` :

{
"_meta": {
"sources": [
"../common/models",
"./models",
"../node_modules/loopback-component-passport/lib/models"
]
},
"User": { // can be an extended model like Customer
"dataSource": "db",
"public": true
},
"AccessToken": {
"dataSource": "db",
"public": false
},
"UserCredential": {
"dataSource": "db",
"public": false
},
"UserIdentity": {
"dataSource": "db",
"public": false
},
...
}

Not sure about backward compatibility, although all tests pass and I did not modify the specs

Note : see https://github.com/pandaiolo/loopback-example-passport-2.x for the loopback-example-passport app amended to take advantage of this module