2015-09-25 62 views

回答

0

這是我最後還是沒買:

應用/會話/ 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'來保存數據(電子郵件&令牌)。

相關問題