/
fixture.js
41 lines (34 loc) · 995 Bytes
/
fixture.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const feathers = require('@feathersjs/feathers');
const memory = require('feathers-memory');
const { AuthenticationService, JWTStrategy } = require('@feathersjs/authentication');
const { LocalStrategy, hooks } = require('../lib');
const { hashPassword, protect } = hooks;
module.exports = (app = feathers()) => {
const authentication = new AuthenticationService(app);
app.set('authentication', {
entity: 'user',
service: 'users',
secret: 'supersecret',
authStrategies: [ 'local', 'jwt' ],
local: {
usernameField: 'email',
passwordField: 'password'
}
});
authentication.register('jwt', new JWTStrategy());
authentication.register('local', new LocalStrategy());
app.use('/authentication', authentication);
app.use('/users', memory({
paginate: {
default: 10,
max: 20
}
}));
app.service('users').hooks({
before: {
create: hashPassword('password')
},
after: protect('password')
});
return app;
};