blob: 9e92a024a98088767e6ff39fbdb5f4fb0c1d1cc6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
const { AuthenticationService, JWTStrategy } = require('@feathersjs/authentication');
const { LocalStrategy } = require('@feathersjs/authentication-local');
const _ = require('lodash');
class NoHashingLocalStrategy extends LocalStrategy {
async comparePassword (entity, password) {
const { entityPasswordField, errorMessage } = this.configuration;
const entityPassword = _.get(entity, entityPasswordField);
if (entityPassword !== password) throw new Error(errorMessage);
return entity;
}
}
module.exports = app => {
const authentication = new AuthenticationService(app);
authentication.register('local', new NoHashingLocalStrategy());
authentication.register('jwt', new JWTStrategy());
app.use('/authentication', authentication);
};
|