You are currently viewing Implementing Forgot Password Feature in the Open Event Android app

Implementing Forgot Password Feature in the Open Event Android app

This blog will illustrate about how forgot password feature is implemented in the Open Event Android app. This feature is quite necessary for users as the user might forget his or her password whenever he needs to login. Thus, this feature utilises only the email of the user. When clicked on “I forgot my password” option, the user is sent an email to reset his/her password!

1. Create the RequestToken, Email and RequestToken response models

The first step is to create all required models. We actually send a POST request to the server and the body of it contains the RequestToken model. The response received is contained in the RequestToken  response model. We create an Email model for our use.

RequestToken class:-

data class RequestToken(val data: Email)

Email class:-

data class Email(val email: String)

RequestTokenResponse class:-

data class RequestTokenResponse(val message: String)

2. Show the option only when correct Email Id is entered.

We create a verification method to verify the email. The app will only send a POST request using a correct email. This method is present in the ViewModel.

fun showForgotPassword(email: String): Boolean {

   if (email.isNotEmpty() && Patterns.EMAIL_ADDRESS.matcher(email).matches()) {

       return true


   return false


2. Update the Login Fragment file.

We add an onclicklistener to the forgot password option. This will call a function in the ViewModel. The function is sendResetPasswordEmail which utilises the actual email of the user entered.

rootView.forgotPassword.setOnClickListener {



3. Update the ViewModel code

We create the sendResetPasswordEmail method. Below code represents that.

fun sendResetPasswordEmail(email: String) {




           .doOnSubscribe {

               progress.value = true

           }.doFinally {

               progress.value = false


               requestTokenSuccess.value = verifyMessage(it.message)

           }, {

               error.value = “Email address not present in server. Please check your email”



3. Create an observer for the requestTokenSuccess variable in the Fragment.

Thus, the final task at hand is to create an observer to observe the vaue of requestTokenSuccess variable. Once the variable is set to a message “Email Sent”, we can clearly notify the user that the email is sent perfectly! (The feature image represents this)

Thus, this is how we have implemented the forgot password feature in the app.


Tags: GSoC18, FOSSASIA, Open Event, Android, Forgot Password

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.