android - task.isSuccessful() 在signInWithEmailAndPassword 中总是给出假
问题描述
我创建了一个注册用户页面和一个登录页面。用户正在注册,他们在 firebase 控制台中可见,但是当我登录时,它总是说密码无效。
以下是我的登录代码:
private void loginUser(String email, String password) {
mAuth.signInWithEmailAndPassword(email, password)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
FirebaseUser user = mAuth.getCurrentUser();
updateUI(user);
} else {
try {
throw task.getException();
}
catch (FirebaseAuthEmailException e){
Toast.makeText(getApplicationContext(), "Invalid Email", Toast.LENGTH_LONG).show();
}
catch (FirebaseAuthInvalidCredentialsException e) {
Toast.makeText(getApplicationContext(), "Invalid Password", Toast.LENGTH_LONG).show();
}
catch (FirebaseAuthException e){
Toast.makeText(getApplicationContext(), "Invalid Credentials", Toast.LENGTH_LONG).show();
}
catch (Exception e) {
e.printStackTrace();
}
}
}
});
}
public void updateUI(FirebaseUser user){
if(user != null){
Toast.makeText(this,"You Signed In successfully",Toast.LENGTH_LONG).show();
startActivity(new Intent(this,MainActivity.class));
}else {
Toast.makeText(this,"You Didn't signed in",Toast.LENGTH_LONG).show();
}
}
}
解决方案
推荐阅读
- kubernetes - 用于 pod 的 kubernetes 扩展资源
- git - 如何在 .gitignore 中排除的子目录上添加 Git 子模块?
- c++ - 在没有任何外部资源(语言/字典)的情况下初始化 tesseract
- delphi - 使用 Delphi 和 TINetHttp,为什么我会得到一个带有一个 url 而不是另一个 url 的 TINetHttp 重定向异常?
- flask - 使用负载平衡器下的自动扩缩功能上传 Google Cloud Storage
- android - React Native 错误:无法从 ` 解析模块`./index` - 多个问题
- java - JaCoco MVN 未知块类型
- reactjs - 如何在 React 的 Material UI 库的选项卡组件中禁用波纹
- python - python logging.basicConfig 不会覆盖现有的日志文件
- apache-spark - 在 Spark 中读取文件时的分区数据