Created
October 14, 2019 22:58
-
-
Save mishra3452/0a8386dfb69cb66af476c44f37055c1c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mindorks.firebaseloginsignup | |
import androidx.appcompat.app.AppCompatActivity | |
import android.os.Bundle | |
import android.text.TextUtils | |
import android.widget.Button | |
import android.widget.EditText | |
import android.widget.Toast | |
import com.google.android.gms.tasks.OnCompleteListener | |
import com.google.firebase.auth.FirebaseAuth | |
class ForgotPasswordActivity : AppCompatActivity() { | |
private lateinit var auth: FirebaseAuth | |
private lateinit var emailEt: EditText | |
private lateinit var resetPasswordBtn: Button | |
private lateinit var back: Button | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_forgot_password_activtiy) | |
auth = FirebaseAuth.getInstance() | |
emailEt = findViewById(R.id.email_edt_text) | |
resetPasswordBtn = findViewById(R.id.reset_pass_btn) | |
back = findViewById(R.id.back_btn) | |
back.setOnClickListener { | |
finish() | |
} | |
resetPasswordBtn.setOnClickListener { | |
var email: String = emailEt.text.toString() | |
if (TextUtils.isEmpty(email)) { | |
Toast.makeText(this, "Please enter email id", Toast.LENGTH_LONG).show() | |
} else { | |
auth.sendPasswordResetEmail(email) | |
.addOnCompleteListener(this, OnCompleteListener { task -> | |
if (task.isSuccessful) { | |
Toast.makeText(this, "Reset link sent to your email", Toast.LENGTH_LONG) | |
.show() | |
} else { | |
Toast.makeText(this, "Unable to send reset mail", Toast.LENGTH_LONG) | |
.show() | |
} | |
}) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment