mercredi 18 mai 2016

Error while processing route: Assertion Failed: You must use Ember.set() to set the property

Maybe I'm using it the wrong way, but I keep getting this error: "Error while processing route: signup Assertion Failed: You must use Ember.set() to set the errorMessageEmail property". This is my code:

import Ember from 'ember';

export default Ember.Route.extend({
    resetController: function(controller, isExiting, transition) {
        if (isExiting) {
            controller.set('errorMessageEmail', false);
            controller.set('errorMessagePassword', false);
            controller.set('errorMessageWrong', false);
        }
},

So everytime I get the error messages on the screen, clean them and then try to change the route, I get this error and I can not do anything, everything gets frozen . But I need to clean the error messages.

import Ember from 'ember';
import { translationMacro as t } from "ember-i18n";
import Cookies from 'ember-cli-js-cookie';

export default Ember.Controller.extend({
hasErrorEmail : Ember.computed.empty('identification'),
hasErrorPassword : Ember.computed.empty('password'),
isDisabled: Ember.computed.and('hasErrorEmail','hasErrorPassword'),
errorMessage:Ember.observer('isDisabled',function(){
    if(this.get('isDisabled')){
        this.set('errorMessageWrong', false);
    }else{
        this.set('errorMessageWrong', true);
    }
}),
i18n: Ember.inject.service(),
session: Ember.inject.service(),
isShowingModal:false,
init: function () {
    this._super();
    if(Cookies.get('checked'))
    {
        this.set('identification',Cookies.get('username'));
        this.set('chekRememberMe',true);
    }
},

watchChecked: function(){
    if(Cookies.get('checked')){
        Cookies.remove('username');
        Cookies.remove('checked');
        this.set('identification','');            
    }  
}.observes('chekRememberMe'),

actions: {
    authenticate: function() {

        var credentials = this.getProperties('identification', 'password');
        var emptyEmail=t("login.empty.username");
        var emptyPassword = t("login.empty.password");
        var wrongPassword=t("login.wrong.password");
        var isEmpty=false;
        if(this.get('hasErrorEmail')){
            this.set('errorMessageEmail', emptyEmail);
            isEmpty=true;
        }
        if(this.get('hasErrorPassword')){
            this.set('errorMessagePassword', emptyPassword);
            isEmpty=true;
        }
        if(!isEmpty){
            this.toggleProperty('isShowingModal');
            this.get('session').authenticate('authenticator:custom', credentials).then(() =>{
                if(this.get('chekRememberMe')){
                    if(!Cookies.get('checked')){                    
                        Cookies.set('username',this.get('identification'),{expires: 31,path:''});
                        Cookies.set('checked',true,{expires: 31,path:''});
                    }
                }
                this.transitionToRoute('home-page');
                this.toggleProperty('isShowingModal');
            }).catch((message) => {
                    this.toggleProperty('isShowingModal');
                    this.set('errorMessageWrong', wrongPassword);
                });
        }else{
            this.set('errorMessageWrong', false);
        }     
    },   
},

});




Aucun commentaire:

Enregistrer un commentaire