首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Ember-simple-auth不会持久化刷新

Ember-simple-auth不会持久化刷新
EN

Stack Overflow用户
提问于 2015-12-17 06:49:39
回答 1查看 342关注 0票数 0

我太沮丧了,我不明白为什么在页面刷新时ember-simple-auth不能持续...我将返回access_token,并遵循文档实现oauth2……

这是我的代码:

authenticators/oauth2.js:

代码语言:javascript
复制
import OAuth2PasswordGrant from 'ember-simple-auth/authenticators/oauth2-password-grant';

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

authorizers/oauth2.js:

代码语言:javascript
复制
import OAuth2Bearer from 'ember-simple-auth/authorizers/oauth2-bearer';

export default OAuth2Bearer.extend();

适配器/application.js:

代码语言:javascript
复制
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和用户名。我可以看到经过身份验证的路由,但如果刷新页面,会话将丢失。

在我的认证对象中,我有:

代码语言:javascript
复制
access_token: "token"
username: "myUserName"

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

代码语言:javascript
复制
authenticator: "simple-auth-authenticator:jwt"
access_token "token"
username: "myUserName"

我不明白为什么这个验证器..我正在使用它,但我已经删除了所有相关的东西。

在我的localStorage中,我有:

代码语言:javascript
复制
{"secure":{"authenticator":"simple-auth-authenticator:jwt","token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI6Im1hcmNlbG9AcHViY3Jhd2xzcC5jb20iLCJpYXQiOjE0NDk1OTY5NDV9.fP11KL2as2mI7ocFojS-H3jUW60XgWCUskTNi4iy1XY","name":"Fatima Alves"},"authenticated":{"authenticator":"authenticator:oauth2","access_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI6Im1hcmNlbG9AcHViY3Jhd2xzcC5jb20iLCJpYXQiOjE0NTAzMDU3MDN9.GKb5A15BBXxgcO9SDrGnxv0CQvkhXQCqvrK65MQ2ROc","name":"Fatima Alves"}}
EN

回答 1

Stack Overflow用户

发布于 2015-12-17 15:19:13

您缺少安全数据中的某些属性,这些属性是OAuth2PasswordGrantAuthenticator正确还原所必需的。

Check out the restore() implementation here

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34323648

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档