parent
							
								
									002bfa6d81
								
							
						
					
					
						commit
						135d7a2c2c
					
				
					 2 changed files with 22 additions and 16 deletions
				
			
		| 
						 | 
				
			
			@ -1,6 +1,8 @@
 | 
			
		|||
import Ember from 'ember';
 | 
			
		||||
 | 
			
		||||
export default Ember.Controller.extend({
 | 
			
		||||
  loading: false,
 | 
			
		||||
 | 
			
		||||
  actions: {
 | 
			
		||||
    authenticate: function() {
 | 
			
		||||
      let credentials = this.getProperties('identification', 'password');
 | 
			
		||||
| 
						 | 
				
			
			@ -9,12 +11,12 @@ export default Ember.Controller.extend({
 | 
			
		|||
 | 
			
		||||
      // Manually clean up because there might not be a transition
 | 
			
		||||
      this.get('flashMessages').clearMessages();
 | 
			
		||||
      this.transitionToRoute('loading').then(() => {
 | 
			
		||||
        session.authenticate(authenticator, credentials).then(null, (error)=> {
 | 
			
		||||
          this.transitionToRoute('login');
 | 
			
		||||
          this.get('flashMessages').error(error.error);
 | 
			
		||||
        });
 | 
			
		||||
      });
 | 
			
		||||
      this.set('loading', true).then(session.authenticate(authenticator, credentials).catch((error) => {
 | 
			
		||||
        this.transitionToRoute('login');
 | 
			
		||||
        this.set('loading', false);
 | 
			
		||||
        this.get('flashMessages').error(error.error);
 | 
			
		||||
      }));
 | 
			
		||||
      this.set('loading', false);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,12 +1,16 @@
 | 
			
		|||
{{#x-application invalidateSession="invalidateSession"}}
 | 
			
		||||
  <form {{action "authenticate" on="submit"}}>
 | 
			
		||||
    <h2>Log In</h2>
 | 
			
		||||
      {{input value=identification type="text" placeholder="Email"}}
 | 
			
		||||
      {{input value=password type="password" placeholder="Password"}}
 | 
			
		||||
      {{input class="button-gray" type="submit" value="Log In"}}
 | 
			
		||||
  </form>
 | 
			
		||||
  <br>
 | 
			
		||||
  <div>
 | 
			
		||||
    Forget your password? {{link-to 'Request a lockout email.' 'users.requestlockouthelp'}}
 | 
			
		||||
  </div>
 | 
			
		||||
  {{#if loading}}
 | 
			
		||||
    {{loading-panel}}
 | 
			
		||||
  {{else}}
 | 
			
		||||
    <form {{action "authenticate" on="submit"}}>
 | 
			
		||||
      <h2>Log In</h2>
 | 
			
		||||
        {{input value=identification type="text" placeholder="Email"}}
 | 
			
		||||
        {{input value=password type="password" placeholder="Password"}}
 | 
			
		||||
        {{input class="button-gray" type="submit" value="Log In"}}
 | 
			
		||||
    </form>
 | 
			
		||||
    <br>
 | 
			
		||||
    <div>
 | 
			
		||||
      Forget your password? {{link-to 'Request a lockout email.' 'users.requestlockouthelp'}}
 | 
			
		||||
    </div>
 | 
			
		||||
  {{/if}}
 | 
			
		||||
{{/x-application}}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Reference in a new issue