Search code examples
passport.jsloopbackjsstrongloop

Do I have to add loopback-component-passport's core models manually?


I installed loopback-component-passport so I can use it with strongloop's Loopback framework. I followed the docs, but after this command: npm install loopback-component-passport, the following files/models are not created:

UserIdentity model
UserCredential model
ApplicationCredential model

These files are used by Loopback for third-party authentication. Do I have to add them manually? Or am I doing something wrong?


Solution

  • Yes, you have to add them manually. You can refer this example, loopback-example-passport on github.

    The reason is the relationships of loopback-component-passport's core models i.e UserIdentity model, UserCredential and ApplicationCredential with Loopback's core model AccessToken and User doesn't come preconfigured which is required for authentication.

    Also, you might notice that the developer extended the models but didn't added any model.js. This is so because there was no need to add any runtime logic. For starters, you might want to extend the core models as per the example and create relationship and acls only. Then you can proceed with custom logic.