0
我正在使用ember-simple-auth-devise。如何在用戶的電子郵件更改時重新授權用於ember-simple-auth-devise的會話
當用戶登錄時,會將用戶的電子郵件和令牌添加到每個請求的標頭中。
當用戶更改他的電子郵件地址時,我可以更新會話的電子郵件,但是這也不會傳播到標題。
什麼是觸發更新會話電子郵件和標題電子郵件的最佳方式?
我正在使用ember-simple-auth-devise。如何在用戶的電子郵件更改時重新授權用於ember-simple-auth-devise的會話
當用戶登錄時,會將用戶的電子郵件和令牌添加到每個請求的標頭中。
當用戶更改他的電子郵件地址時,我可以更新會話的電子郵件,但是這也不會傳播到標題。
什麼是觸發更新會話電子郵件和標題電子郵件的最佳方式?
這是我最後還是沒買:
應用/會話/ custom.js
import Ember from 'ember';
import DS from 'ember-data';
import Session from '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 the session email when the user successfully changes their 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);
}
}),
});
看來updateStore上的會話沒有得到,當你設置「secure.email」叫但是當你設置'email'的時候它確實會被調用,但是隻是設置'email'是不夠的,因爲updateStore使用'secure.email'來保存數據(電子郵件&令牌)。