验证用户身份验证的问题
Problem with verifying the user authentication
我是 java 编程的初学者 我正在尝试在应用程序中创建两种方式的登录系统,第一种是电子邮件,第二种是 phone 号码,但我无法识别使用 phone 号码或电子邮件登录的用户
在我的初始屏幕上,首先我检查了用户是否为 null 或者如果它不为 null 然后第二个我检查了用户电子邮件是否已验证如果用户电子邮件已验证则用户可以转到主应用程序但如果用户电子邮件没有经过验证,那么他应该去验证页面,在那里他应该首先验证他的帐户,但是如果用户使用他的 phone 号码登录,他应该直接去主应用程序但我的问题是什么时候注册phone 号码,然后我打开应用程序,它会转到验证电子邮件页面。
public class SplashScreen extends AppCompatActivity
{
ImageView icon;
TextView app;
RelativeLayout relativeLayout;
Animation layout;
private FirebaseAuth mAuth;
FirebaseUser firebaseUser;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash_screen);
firebaseUser = FirebaseAuth.getInstance().getCurrentUser();
mAuth = FirebaseAuth.getInstance();
app = findViewById(R.id.splash_scren_app);
relativeLayout = findViewById(R.id.splash_srceen);
icon = findViewById(R.id.splash_srceen_icon);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
relativeLayout.setVisibility(View.VISIBLE);
relativeLayout.setAnimation(layout);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
app.setVisibility(View.VISIBLE);
icon.setVisibility(View.VISIBLE);
}
},500);
}
},1000);
if (firebaseUser!=null)
{
new Handler().postDelayed(new Runnable() {
@Override
public void run()
{
if (firebaseUser.isEmailVerified())
{
Intent intent = new Intent(SplashScreen.this,MainActivity.class);
startActivity(intent);
finish();
}
else
{
Intent intent = new Intent(SplashScreen.this,EmailVerification.class);
startActivity(intent);
finish();
}
}
},5000);
}
else
{
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(SplashScreen.this,WelcomeScreen.class);
startActivity(intent);
finish();
}
},5000);
}
}
}
你的逻辑有问题
if (firebaseUser.isEmailVerified())
{
Intent intent = new Intent(SplashScreen.this,MainActivity.class);
startActivity(intent);
finish();
}
else
{
Intent intent = new Intent(SplashScreen.this,EmailVerification.class);
startActivity(intent);
finish();
}
改为这样做
if (firebaseUser.isEmailVerified() || firebase.getPhoneNumber() != null)
{
Intent intent = new Intent(SplashScreen.this,MainActivity.class);
startActivity(intent);
finish();
}
else
{
if(firebaseUser.isEmailVerified()){
Intent intent = new Intent(SplashScreen.this,EmailVerification.class);
startActivity(intent);
finish();
}
else if (firebase.getPhoneNumber() != null){
//go to the phone verify activity
}
}
我是 java 编程的初学者 我正在尝试在应用程序中创建两种方式的登录系统,第一种是电子邮件,第二种是 phone 号码,但我无法识别使用 phone 号码或电子邮件登录的用户 在我的初始屏幕上,首先我检查了用户是否为 null 或者如果它不为 null 然后第二个我检查了用户电子邮件是否已验证如果用户电子邮件已验证则用户可以转到主应用程序但如果用户电子邮件没有经过验证,那么他应该去验证页面,在那里他应该首先验证他的帐户,但是如果用户使用他的 phone 号码登录,他应该直接去主应用程序但我的问题是什么时候注册phone 号码,然后我打开应用程序,它会转到验证电子邮件页面。
public class SplashScreen extends AppCompatActivity
{
ImageView icon;
TextView app;
RelativeLayout relativeLayout;
Animation layout;
private FirebaseAuth mAuth;
FirebaseUser firebaseUser;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash_screen);
firebaseUser = FirebaseAuth.getInstance().getCurrentUser();
mAuth = FirebaseAuth.getInstance();
app = findViewById(R.id.splash_scren_app);
relativeLayout = findViewById(R.id.splash_srceen);
icon = findViewById(R.id.splash_srceen_icon);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
relativeLayout.setVisibility(View.VISIBLE);
relativeLayout.setAnimation(layout);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
app.setVisibility(View.VISIBLE);
icon.setVisibility(View.VISIBLE);
}
},500);
}
},1000);
if (firebaseUser!=null)
{
new Handler().postDelayed(new Runnable() {
@Override
public void run()
{
if (firebaseUser.isEmailVerified())
{
Intent intent = new Intent(SplashScreen.this,MainActivity.class);
startActivity(intent);
finish();
}
else
{
Intent intent = new Intent(SplashScreen.this,EmailVerification.class);
startActivity(intent);
finish();
}
}
},5000);
}
else
{
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(SplashScreen.this,WelcomeScreen.class);
startActivity(intent);
finish();
}
},5000);
}
}
}
你的逻辑有问题
if (firebaseUser.isEmailVerified())
{
Intent intent = new Intent(SplashScreen.this,MainActivity.class);
startActivity(intent);
finish();
}
else
{
Intent intent = new Intent(SplashScreen.this,EmailVerification.class);
startActivity(intent);
finish();
}
改为这样做
if (firebaseUser.isEmailVerified() || firebase.getPhoneNumber() != null)
{
Intent intent = new Intent(SplashScreen.this,MainActivity.class);
startActivity(intent);
finish();
}
else
{
if(firebaseUser.isEmailVerified()){
Intent intent = new Intent(SplashScreen.this,EmailVerification.class);
startActivity(intent);
finish();
}
else if (firebase.getPhoneNumber() != null){
//go to the phone verify activity
}
}