如何检查用户是否验证了邮箱?
How to check whether user has verify the email?
我这里有问题。我想知道用户是否已经验证了电子邮件。如果用户通过单击给定的 link 验证了电子邮件,应用程序应自动转到主屏幕。否则,用户可能会停留在同一页面上。
下面是我的部分代码:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_email_verification);
emailVerify = findViewById(R.id.emailVerify);
final FirebaseUser user = auth.getCurrentUser();
Intent intent = getIntent();
name = intent.getStringExtra("name");
email = intent.getStringExtra("email");
password = intent.getStringExtra("password");
emailVerify.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
user.sendEmailVerification().addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
storeNewUsersData();
Toast.makeText(v.getContext(), "Verification email has been sent.", Toast.LENGTH_SHORT).show();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.d(TAG, "onFailure: Email not sent " + e.getMessage());
}
});
//check whether the user has verified the email and go to homeScreen
}
});
}
https://www.youtube.com/watch?v=Wf7DDIaRYjk 本教程可能对我有所帮助,我从中实现了我的教程。
试试这个:
public void verifyEmail() {
if (firebaseAuth.getCurrentUser().isEmailVerified()) { //FirbaseUser must not be null!
Toast.makeText(view.getContext(), "Email has been verified.", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(view.getContext(), "Email has not been verified.", Toast.LENGTH_SHORT).show();
}
}
我这里有问题。我想知道用户是否已经验证了电子邮件。如果用户通过单击给定的 link 验证了电子邮件,应用程序应自动转到主屏幕。否则,用户可能会停留在同一页面上。
下面是我的部分代码:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_email_verification);
emailVerify = findViewById(R.id.emailVerify);
final FirebaseUser user = auth.getCurrentUser();
Intent intent = getIntent();
name = intent.getStringExtra("name");
email = intent.getStringExtra("email");
password = intent.getStringExtra("password");
emailVerify.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
user.sendEmailVerification().addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
storeNewUsersData();
Toast.makeText(v.getContext(), "Verification email has been sent.", Toast.LENGTH_SHORT).show();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.d(TAG, "onFailure: Email not sent " + e.getMessage());
}
});
//check whether the user has verified the email and go to homeScreen
}
});
}
https://www.youtube.com/watch?v=Wf7DDIaRYjk 本教程可能对我有所帮助,我从中实现了我的教程。
试试这个:
public void verifyEmail() {
if (firebaseAuth.getCurrentUser().isEmailVerified()) { //FirbaseUser must not be null!
Toast.makeText(view.getContext(), "Email has been verified.", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(view.getContext(), "Email has not been verified.", Toast.LENGTH_SHORT).show();
}
}