簡體   English   中英

灰燼簡單身份驗證不持久刷新

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

我很沮喪,我無法弄清楚為什么當頁面刷新時ember-simple-auth不會持久...我返回了access_token,我按照文檔來實現oauth2...。

那是我的代碼:

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:

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

export default OAuth2Bearer.extend();

適配器/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'
});

我正在返回access_token和用戶名。 我可以看到經過身份驗證的路由,但是如果刷新頁面,則該會話將丟失。

在經過身份驗證的對象中,我有:

access_token: "token"
username: "myUserName"

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

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

我不知道為什么要使用這個身份驗證器。我正在使用它,但是我已經刪除了所有相關內容。

在我的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"}}

您缺少安全數據中的某些屬性, OAuth2PasswordGrantAuthenticator才能正確還原這些屬性。

在此處檢查restore()實現

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM