feathersjs中需要添加多个usernameField
Need to add more than usernameField in feathersjs
我是 feathersjs 的新手,我正在使用它构建后端服务器,需要添加 2 种本地身份验证方式,通过电子邮件或移动
我已经将新本地添加到 config/default.json
,如下所示
"local-mobile": {
"usernameField": "mobile",
"passwordField": "password"
},
这是我的 authentication.js 文件
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());
};
在src/authentication
但是当我使用 postman 向身份验证端点发送 post 请求时,正文如下
{
"strategy":"local-mobile",
"mobile":".......",
"password":"........"
}
响应即将到来
{
"name": "NotAuthenticated",
"message": "Invalid authentication information",
"code": 401,
"className": "not-authenticated",
"errors": {}
}
有什么想法吗?
如果要允许通过 authenticate
端点进行身份验证,还必须将策略添加到 authStrategies configuration setting in your config/default.json
(feathers-chat example):
{
"authentication": {
// ...
"authStrategies": [
"jwt",
"local",
"local-mobile",
]
}
// ...
}
我是 feathersjs 的新手,我正在使用它构建后端服务器,需要添加 2 种本地身份验证方式,通过电子邮件或移动
我已经将新本地添加到 config/default.json
,如下所示
"local-mobile": {
"usernameField": "mobile",
"passwordField": "password"
},
这是我的 authentication.js 文件
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());
};
在src/authentication
但是当我使用 postman 向身份验证端点发送 post 请求时,正文如下
{
"strategy":"local-mobile",
"mobile":".......",
"password":"........"
}
响应即将到来
{
"name": "NotAuthenticated",
"message": "Invalid authentication information",
"code": 401,
"className": "not-authenticated",
"errors": {}
}
有什么想法吗?
如果要允许通过 authenticate
端点进行身份验证,还必须将策略添加到 authStrategies configuration setting in your config/default.json
(feathers-chat example):
{
"authentication": {
// ...
"authStrategies": [
"jwt",
"local",
"local-mobile",
]
}
// ...
}