DEV Community

loading...

Kotlin Firebase Authentication – Send Reset Password Email / Forgot Password | Android

loizenai profile image loizenai ・2 min read

https://grokonez.com/android/kotlin-firebase-authentication-send-reset-password-email-forgot-password-android

Kotlin Firebase Authentication – Send Reset Password Email / Forgot Password | Android

In previous post, we have known way to implement Sign up, Sign in/out, Verify Email. Today, we continue to take a look at way to send Reset Password Email in case User forgot Password.

*Note: This tutorial bases on code in related post:
Kotlin Firebase Authentication – How to Sign Up, Sign In, Sign Out, Verify Email | Android

We just add an Activity to App for handling Reset Password Email and some statements to old code for logic.

I. Way to do

1. Add Firebase Auth to Android App

Read Kotlin Firebase Authentication – How to Sign Up, Sign In, Sign Out, Verify Email | Android and follow steps to enable and implement Firebase Auth in your Android App.

2. Send a password reset email

Use sendPasswordResetEmail() method:


private var mAuth: FirebaseAuth? = null
//...
mAuth = FirebaseAuth.getInstance()

mAuth!!.sendPasswordResetEmail(email)
        .addOnCompleteListener { task ->
            if (task.isSuccessful) {
                // successful!
            } else {
                // failed!
            }
        }

We can customize the email template in Firebase console:
firebase-auth-email-password-mail-template-reset

II. Practice

1. Goal

We will build an Android App that can:

  • create Account, sign in/sign out, send email verification.
  • display current status/user information with verified email status. (all things above are from previous tutorial)
  • send reset password email in case user forgot password.

More at:

https://grokonez.com/android/kotlin-firebase-authentication-send-reset-password-email-forgot-password-android

Kotlin Firebase Authentication – Send Reset Password Email / Forgot Password | Android

Discussion (0)

Forem Open with the Forem app