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:

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.

kotlin-email-reset-password-goal-2-screen

2. Technology

– Gradle 3.0.1
– Android Studio 3.x
– Firebase Android SDK 11.x

3. Project Structure

kotlin-email-reset-password-structure

4. Step by step
4.1 Create Android Project

– Generate new Android Project with package com.javasampleapproach.kotlin.firebase.auth.
– Follow these steps to add Firebase to Android Project.
– Don’t forget to enable Firebase Auth:
firebaseauth-enable-email

4.2 LoginActivity

4.3 ResetPasswordActivity

4.4 Set main launcher & new activity

Open AndroidManifest.xml:
– make the LoginActivity.java as launcher activity (set it as the first screen).
– add ResetPasswordActivity as activity.

4.5 Run & Check result

– Use Android Studio, build and Run your Android App.

– Click on Forgot your password?, then fill in Email and click on RESET PASSWORD button:
kotlin-email-reset-password-goal-2

– Check your email:
kotlin-email-reset-password-email-result

– Follow instruction, click on the link inside, the browser shows a dialog, enter your new password:
firebase-auth-email-password-reset-mail-result-web-1

– The result:
firebase-auth-email-password-reset-mail-result-web-2

III. Source code

Kotlin-FirebaseAuth-reset-password-email

By JavaSampleApproach | December 15, 2017.


Related Posts


Got Something To Say:

Your email address will not be published. Required fields are marked *

*