I'm new to feathersjs I'm building a backend server using it, and need to add 2 ways of local authentication, by email, or mobile
I've already added new local to the config/default.json
as the following
"local-mobile": {
"usernameField": "mobile",
"passwordField": "password"
},
here's my authentication.js file
const { AuthenticationService, JWTStrategy } = require('@feathersjs/authentication');
const { LocalStrategy } = require('@feathersjs/authentication-local');
const { expressOauth } = require('@feathersjs/authentication-oauth');
module.exports = app => {
const authentication = new AuthenticationService(app);
authentication.register('jwt', new JWTStrategy());
authentication.register('local', new LocalStrategy());
authentication.register('local-mobile', new LocalStrategy());
app.use('/authentication', authentication);
app.configure(expressOauth());
};
in src/authentication
But when I send a post request to the authentication endpoint using postman with the following body
{
"strategy":"local-mobile",
"mobile":".......",
"password":"........"
}
the response is coming
{
"name": "NotAuthenticated",
"message": "Invalid authentication information",
"code": 401,
"className": "not-authenticated",
"errors": {}
}
any Idea ?
If you want to allow authentication through the authenticate
endpoint, the strategy also has to be added to the authStrategies configuration setting in your config/default.json
(feathers-chat example):
{
"authentication": {
// ...
"authStrategies": [
"jwt",
"local",
"local-mobile",
]
}
// ...
}