Need to wait for currentUser promise
Also, add ‘id’ to password change payload
This commit is contained in:
		
							parent
							
								
									45eca0227c
								
							
						
					
					
						commit
						be1b58a380
					
				
					 2 changed files with 5 additions and 5 deletions
				
			
		| 
						 | 
				
			
			@ -16,6 +16,7 @@ export default Ember.Controller.extend({
 | 
			
		|||
      let options = {
 | 
			
		||||
        method: 'POST',
 | 
			
		||||
        data: {
 | 
			
		||||
          id: this.get('session.currentUser.id'),
 | 
			
		||||
          password: this.get('password'),
 | 
			
		||||
        },
 | 
			
		||||
      };
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,13 +4,12 @@ export default Ember.Route.extend({
 | 
			
		|||
  beforeModel: function(transition) {
 | 
			
		||||
    this._super(transition);
 | 
			
		||||
 | 
			
		||||
    if (this.get('session.currentUser.role') !== 'A') {
 | 
			
		||||
    this.get('session.currentUser').then((currentUser) => {
 | 
			
		||||
      let user_id = transition.params['protected.users.show'].user_id;
 | 
			
		||||
      let currentUser_id = this.get('session.currentUser.id')
 | 
			
		||||
      if (currentUser_id !== user_id) {
 | 
			
		||||
        this.transitionTo('protected.users.show', currentUser_id);
 | 
			
		||||
      }
 | 
			
		||||
      if (!currentUser.get('isAdmin') && currentUser.get('id') !== user_id) {
 | 
			
		||||
        this.transitionTo('protected.users.index');
 | 
			
		||||
      }
 | 
			
		||||
    })
 | 
			
		||||
  },
 | 
			
		||||
 | 
			
		||||
  model: function(params) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Reference in a new issue