mercredi 16 décembre 2015

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....

That's my code:

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();

adapters/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. 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:

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




Aucun commentaire:

Enregistrer un commentaire