Ember.js - How can I save data to session from authenticator? -


i have tried doing this.get('session') gives me nothing.

i want save data session

i seem information need authenticator can't seem able pass around. (tried couple of methods suggested on none seem able work autheticator)

import ember 'ember';   import torii 'ember-simple-auth/authenticators/torii';    const { service } = ember.inject;    export default torii.extend({     torii: service('torii'),     authenticate(options) {       return this._super(options).then(function (data) {         console.log(data);       });     }   }); 

caller of autheticator (is info need accessible here already?)

import ember 'ember';  export default ember.controller.extend({    session: ember.inject.service('session'),     actions: {       authenticatesession() {         this.get('session').authenticate('authenticator:torii', 'google-token');       },       invalidatesession() {         this.get('session').invalidate();       }     } }); 

your authenticator's authenticate method not resolve anything. change to

import ember 'ember'; import torii 'ember-simple-auth/authenticators/torii';  const { service } = ember.inject;  export default torii.extend({   torii: service('torii'),   authenticate(options) {     return this._super(options).then(function (data) {       console.log(data);       return data;     });   } }); 

to have attributes in data available via session's data.authenticated property, e.g. this.get('session.data.authenticated.token').

of course in case can remove overridden authenticate method if don't need logging.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -