简体   繁体   English

灰烬简单身份验证不持久刷新

[英]Ember-simple-auth does not persist refresh's

I am so frustrated , i can't figure it out why ember-simple-auth does not persist when the page refresh's... I'm returning the access_token and i follow the docs to implement oauth2.... 我很沮丧,我无法弄清楚为什么当页面刷新时ember-simple-auth不会持久...我返回了access_token,我按照文档来实现oauth2...。

That's my code: 那是我的代码:

authenticators/oauth2.js: authenticators / oauth2.js:

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

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

authorizers/oauth2.js: authorizers / oauth2.js:

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

export default OAuth2Bearer.extend();

adapters/application.js: 适配器/application.js:

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'
});

I'm returning the access_token and username. 我正在返回access_token和用户名。 I'm able to see authenticated routes, but if i refresh the page, the session will be lost. 我可以看到经过身份验证的路由,但是如果刷新页面,则该会话将丢失。

In my authenticated object i have: 在经过身份验证的对象中,我有:

access_token: "token"
username: "myUserName"

And in my secure object i have: 在我的安全对象中,我有:

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

I can't figure it out why this authenticator.. I was using it but i already delete everything related. 我不知道为什么要使用这个身份验证器。我正在使用它,但是我已经删除了所有相关内容。

In my localStorage i have: 在我的localStorage中,我有:

{"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"}}

You're missing some properties in the secure data which are required for the OAuth2PasswordGrantAuthenticator to restore correctly. 您缺少安全数据中的某些属性, OAuth2PasswordGrantAuthenticator才能正确还原这些属性。

Check out the restore() implementation here . 在此处检查restore()实现

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM