简体   繁体   English

Emberfire:如何检查登录失败?

[英]Emberfire: How can I check that a login failed?

I'm using emberJS with emberfire to do email/password login system. 我在emberfire中使用emberJS来进行电子邮件/密码登录系统。 I am using Torii (which is used inside of emberfire) to handle authentication. 我正在使用Torii(在emberfire内部使用)来处理身份验证。

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 在控制台上,输入错误的电子邮件/密码时会看到以下内容

在此处输入图片说明

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. 但是我不确定如何首先检查该信息。

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. 因此,一旦进入错误状态,就执行错误处理逻辑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM