Ember - How to transfer a property from a Routes file to a Handlebar template with 401 returned

The situation is that I have a login screen that works, except in cases of failed login (401 is not authorized). Basically, it is very simple right now, the handle (template) is trying to access the property from the route to determine if the call to the back end (rails) has completed.

{{#if loginFailed}}
  <div class="alert">Invalid username or password.</div>
{{/if}}

The Route file looks something like this: I missed some secret code or working code that is not needed:

import Ember from 'ember';
import ajax from 'ic-ajax';

export default Ember.Route.extend({

loginFailed: false,
isProcessing: false,

beforeModel: function(){
    //some stuff 
},

actions: {
login: function() {
    this.setProperties({
      loginFailed: false,
      isProcessing: true
    });
    var _this = this;

    ajax({
        url: //something,
        type: 'post',
        crossDomain: true,
        data: //some stuff,
  }).then(
            function(result) {
                //logging in logic all works
            },
            function(error){
                if (error.jqXHR.status === 401)
                {

                    _this.set('isProcessing', false);
                    _this.set("loginFailed", true);
                }
            }
        );


  },
},

reset: function() {
  this.set('isProcessing', false);
  this.controller.set('password', '');
  this.controller.set('username', '');
}
});

I did some debugging and it really fell into the error block for the ajax alliance, but it seems like that is just shit. I think this is shit because 401 limited resources led me to that conclusion.

, loginFailed - , , 401, , .

, , .

, ember -v :

version: 1.13.8
node: 0.12.7
npm: 2.13.4
os: win32 x64
+4
2

.

_this.set("controller.loginFailed", true);

-

+3

. , .

, , .

, ​​ . , . :

{{#if loginFailed}}
  <div class="alert">Invalid username or password.</div>
{{/if}}

:

{{my-login-component loginPressed="login" loginData=model}}

js .

0

All Articles