Ember.js 使用ember simple auth token赢得的令牌请求';不包括标识字段
A有一个Ember(v2.12.0-beta.1)应用程序,它使用Ember简单身份验证令牌来请求JWT 重要的部分发生在登录控制器中Ember.js 使用ember simple auth token赢得的令牌请求';不包括标识字段,ember.js,ember-simple-auth,Ember.js,Ember Simple Auth,A有一个Ember(v2.12.0-beta.1)应用程序,它使用Ember简单身份验证令牌来请求JWT 重要的部分发生在登录控制器中 export default Ember.Controller.extend({ session: Ember.inject.service(), // Properties username: 'user1', password: 'password123', // Actions actions: {
export default Ember.Controller.extend({
session: Ember.inject.service(),
// Properties
username: 'user1',
password: 'password123',
// Actions
actions: {
login(username, password) {
console.log('Attempting login...');
let creds = this.getProperties('username', 'password');
let authenticator = 'authenticator:jwt';
this.get('session').authenticate(authenticator, creds).then(function() {
console.log('LOGIN SUCCESS')
}, function() {
console.log('LOGIN FAIL')
});
}
}
});
提交表单时,浏览器会发出一个请求,我的后端会收到该请求
问题是请求中只包含密码。请求主体的形式为{“password”:“password123”}
,但它应该类似于{“username”:“user1”,“password”:“password123”}
。当然,登录尝试失败,并且会打印登录失败
为什么令牌请求中不包括用户名
我尝试使用早期版本的ember simple auth token和ember simple auth
以下是我的配置:
ENV['ember-simple-auth'] = {
authorizer: 'authorizer:token',
};
ENV['ember-simple-auth-token'] = {
serverTokenEndpoint: 'http://127.0.0.1:6003/token',
identificationField: 'username',
passwordField: 'password',
tokenPropertyName: 'token',
authorizationPrefix: 'Bearer ',
authorizationHeaderName: 'Authorization',
refreshAccessTokens: false,
};
ember简单身份验证令牌
希望传递给authenticate
的凭据对象的格式为:
{
identification: <username>,
password: <password>
}
在这种情况下发送的请求是:
{
"password":"password123",
"username":"user1"
}
对这个问题有一些看法
{
"password":"password123",
"username":"user1"
}