ember.jsemberfiretorii

Emberfire: How can I check that a login failed?


I'm using emberJS with emberfire to do email/password login system. I am using Torii (which is used inside of emberfire) to handle authentication.

So far, everything works fine and dandy. I would now like to add a feature that tells the user that their username/password was incorrect IF the login failed.

On my console, I see the following when I give a bad email/password

enter image description here

Which I think means that this is the response because the login failed. My question now is what do I do with this information? My end goal is to change the user interface to say "Hey! Your login credentials were bad!". But I'm not sure how to check for that information in the first place.


Solution

  • Ok. I figured out something that works.

    I have the following snippet of code

    this.get('session').open('firebase', 
                    { provider: "password", 
                      email: username,
                      password: password 
                    });
    

    And I needed to append to it

    this.get('session').open('firebase', 
                        { provider: "password", 
                          email: username,
                          password: password 
                        }).then( function(data) {
                                // successful state
                         }, function(error) {
                                // Error state
                         }
    

    So once I get into the error state, then I do my error-handling logic.