We can now use the generator to add some local authentication to the app by running
feathers generate authentication
The directory has changed:
The users service
The generator has added a
users service to the app
because local authentication requires we keep a database of users.
This caused the following modules to be added:
src/services/users contains the rest of the
users.service.js configures the service.
users.hooks.js configures the hooks for the service. The
authenticate('jwt')hooks ensure only authenticated users can perform method calls. The
hashPassword()hook encrypts the password when a new user is added.
users.filters.js will allow you to control which clients are notified when a user is mutated.
test/services/users.test.js tests that the service gets configured.
The service has to be wired into the app, so the generator made the following changes:
The authentication service
The generator also added an
authentication service to the app.
Its responsible for authenticating clients against the
generating JWT tokens and verifying them.
authentication service is a custom service, not a database service.
It has no model, no database table, no hooks to run when one of its methods is called.
- So instead of creating a set of folders as was done for
users, the generator creates the only module
authenticationneeds as src/authentication.js
This service also has to be wired into the app, so the generator made the following change:
The changes to our app have introduced new dependencies and they need to be defined.
users service was created as its needed for the local authentication.
That generated code contains no surprises for us as we have covered it before.
Next, we will generate a new service.