Ember-simple-auth不会持续刷新

时间:2015-12-16 22:49:39

标签: javascript authentication ember.js ember-simple-auth

我很沮丧,我无法弄清楚为什么ember-simple-auth 页面刷新时不会持续...我正在返回access_token,我按照文档实现oauth2 ....

这是我的代码:

认证器/ oauth2.js:

node_modules

授权人/ oauth2.js:

import OAuth2PasswordGrant from 'ember-simple-auth/authenticators/oauth2-password-grant';

export default OAuth2PasswordGrant.extend({
  serverTokenEndpoint: 'http://localhost:3000/users/compare'
});

适配器/ application.js中:

import OAuth2Bearer from 'ember-simple-auth/authorizers/oauth2-bearer';

export default OAuth2Bearer.extend();

我正在返回access_token和用户名。我能够看到经过身份验证的路由,但如果我刷新页面,会话将会丢失。

在我的身份验证对象中,我有:

import DS from 'ember-data';
import DataAdapterMixin from 'ember-simple-auth/mixins/data-adapter-mixin';

const {
  JSONAPIAdapter
} = DS;

export default JSONAPIAdapter.extend(DataAdapterMixin, {
  authorizer: 'authorizer:oauth2',
  host: 'http://localhost:3000'
});

在我的安全对象中,我有:

access_token: "token"
username: "myUserName"

我无法弄明白为什么这个验证器......我正在使用它,但我已经删除了所有相关内容。

在我的本地存储中我有:

authenticator: "simple-auth-authenticator:jwt"
access_token "token"
username: "myUserName"

1 个答案:

答案 0 :(得分:0)

您遗漏了OAuth2PasswordGrantAuthenticator正确还原所需的安全数据中的某些属性。

Check out the restore() implementation here

相关问题