邮件未验证
email is not verified
在我的应用程序中,首先我验证用户电子邮件,然后我验证用户电子邮件我设置了对话框 activity 以通知用户检查电子邮件并验证电子邮件我在对话框中有关闭按钮 activity 如果用户点击它对话框将被关闭
我首先实现了 override fun onResume() 方法 activity 并且在这个方法中我通过 auth.getInstance() 检查用户是否验证了电子邮件。currentUser.isEmailVerified
i 运行 这个应用程序我收到了电子邮件并成功验证但是在 onResume() 方法中 auth.getInstance().currentUser.isEmailVerified returns false
auth.createUserWithEmailAndPassword(binding.email.text.toString(),binding.password.text.toString()).addOnCompleteListener { task->
Log.d("userAuthenticated","yes")
if(task.isSuccessful)
{
val currUser=auth.currentUser
Log.d("TaskIsSuccessful","Yes")
currUser!!.sendEmailVerification().addOnSuccessListener {
Log.d("Emailissent","yes")
uniqueFirebaseAuthId=task.result!!.user!!.uid.toString()
val sentEmailbinding=ActivityEmailVarificationSignUpBinding.inflate(layoutInflater)
val dialog = Dialog(this@SignUp)
dialog.setContentView(sentEmailbinding.root)
dialog.setCanceledOnTouchOutside(true)
dialog.setCancelable(false)
sentEmailbinding.closebtn.setOnClickListener{
dialog.dismiss()
Log.d("Iamback","Yes")
}
dialog.show()
Log.d("verified",currUser.isEmailVerified.toString())
Log.d("Dialogshown","yes")
Log.d("uniqueFirebaseAuthValue","${uniqueFirebaseAuthId} ")
}.addOnFailureListener {
Log.d("emailauthverification",it.toString())
}
}
task.addOnFailureListener {
Log.d("TaskFail",it.toString())
}
onResume() 函数
override fun onResume() {
super.onResume()
val userEnterdName=binding.uiqueusername.toString()
val currUser=FirebaseAuth.getInstance().currentUser
if(currUser!!.isEmailVerified) {
val verifiedUser=UseratFirebase(userEnterdName,binding.email.toString(),binding.password.toString())
val uniqueAuthId=uniqueFirebaseAuthId.toString()
database.reference.child("users").child(uniqueAuthId).setValue(verifiedUser).addOnSuccessListener {
val intent=Intent(this@SignUp,SignIn::class.java)
intent.putExtra("Email",binding.email.text.toString())
intent.putExtra("password",binding.email.toString())
}.addOnFailureListener {
Toast.makeText(this@SignUp,"Error occured while stroting data",Toast.LENGTH_LONG).show()
}
}
else
{
Log.d("Curruser", "${currUser.toString() } -> ${currUser.isEmailVerified}")
Toast.makeText(this@SignUp,"Please verify Your Account",Toast.LENGTH_LONG).show()
}
}
验证用户的电子邮件地址发生在另一个应用程序中(您在邮件应用程序中单击 link,然后它会在浏览器中验证该操作),因此您的应用程序不会立即意识到这一点。
信息编码在用户的 ID 令牌中,每小时自动刷新一次,或者在用户再次登录时刷新。因此,您可以 wait/force 用户再次登录,或者您可以通过调用 user.getIdToken(true)
or user.reload()
.
告诉 SDK 刷新令牌
在我的应用程序中,首先我验证用户电子邮件,然后我验证用户电子邮件我设置了对话框 activity 以通知用户检查电子邮件并验证电子邮件我在对话框中有关闭按钮 activity 如果用户点击它对话框将被关闭
我首先实现了 override fun onResume() 方法 activity 并且在这个方法中我通过 auth.getInstance() 检查用户是否验证了电子邮件。currentUser.isEmailVerified
i 运行 这个应用程序我收到了电子邮件并成功验证但是在 onResume() 方法中 auth.getInstance().currentUser.isEmailVerified returns false
auth.createUserWithEmailAndPassword(binding.email.text.toString(),binding.password.text.toString()).addOnCompleteListener { task->
Log.d("userAuthenticated","yes")
if(task.isSuccessful)
{
val currUser=auth.currentUser
Log.d("TaskIsSuccessful","Yes")
currUser!!.sendEmailVerification().addOnSuccessListener {
Log.d("Emailissent","yes")
uniqueFirebaseAuthId=task.result!!.user!!.uid.toString()
val sentEmailbinding=ActivityEmailVarificationSignUpBinding.inflate(layoutInflater)
val dialog = Dialog(this@SignUp)
dialog.setContentView(sentEmailbinding.root)
dialog.setCanceledOnTouchOutside(true)
dialog.setCancelable(false)
sentEmailbinding.closebtn.setOnClickListener{
dialog.dismiss()
Log.d("Iamback","Yes")
}
dialog.show()
Log.d("verified",currUser.isEmailVerified.toString())
Log.d("Dialogshown","yes")
Log.d("uniqueFirebaseAuthValue","${uniqueFirebaseAuthId} ")
}.addOnFailureListener {
Log.d("emailauthverification",it.toString())
}
}
task.addOnFailureListener {
Log.d("TaskFail",it.toString())
}
onResume() 函数
override fun onResume() {
super.onResume()
val userEnterdName=binding.uiqueusername.toString()
val currUser=FirebaseAuth.getInstance().currentUser
if(currUser!!.isEmailVerified) {
val verifiedUser=UseratFirebase(userEnterdName,binding.email.toString(),binding.password.toString())
val uniqueAuthId=uniqueFirebaseAuthId.toString()
database.reference.child("users").child(uniqueAuthId).setValue(verifiedUser).addOnSuccessListener {
val intent=Intent(this@SignUp,SignIn::class.java)
intent.putExtra("Email",binding.email.text.toString())
intent.putExtra("password",binding.email.toString())
}.addOnFailureListener {
Toast.makeText(this@SignUp,"Error occured while stroting data",Toast.LENGTH_LONG).show()
}
}
else
{
Log.d("Curruser", "${currUser.toString() } -> ${currUser.isEmailVerified}")
Toast.makeText(this@SignUp,"Please verify Your Account",Toast.LENGTH_LONG).show()
}
}
验证用户的电子邮件地址发生在另一个应用程序中(您在邮件应用程序中单击 link,然后它会在浏览器中验证该操作),因此您的应用程序不会立即意识到这一点。
信息编码在用户的 ID 令牌中,每小时自动刷新一次,或者在用户再次登录时刷新。因此,您可以 wait/force 用户再次登录,或者您可以通过调用 user.getIdToken(true)
or user.reload()
.