ember.js - How to re-authorize the session for ember-simple-auth-devise when user's email changes -


i'm using ember-simple-auth-devise.

when user logs in, user's email , token added headers of every request.

when user changes email address, can update session's email not propagate header well.

what best way trigger update session email , header email?

here's did in end:

app/sessions/custom.js

import ember 'ember'; import ds 'ember-data'; import session 'simple-auth/session';  export default session.extend({   currentuser: function() {     var userid = this.get('secure.userid');      if (!ember.isempty(userid)) {       return ds.promiseobject.create({         promise: this.container.lookup('store:main').find('user', userid)       });     }   }.property('secure.userid'),    // update session email when user changes email.   updateemail: ember.observer('currentuser.email', function() {     var currentuseremail = this.get('currentuser.email'),         sessionemail = this.get('secure.email');      if(currentuseremail && !this.get('currentuser.isdirty') && sessionemail !== currentuseremail) {       this.set('secure.email', currentuseremail);       this.set('email', currentuseremail);     }   }), }); 

it seems updatestore on session doesn't called when set 'secure.email' called when set 'email', however, setting 'email' not sufficient because updatestore uses 'secure.email' persist data (email & token).


Comments