Flutter
...
Authentication
Reset Password
9 min
how to add user reset password to a flutter app introduction it’s a fact that as soon as you introduce passwords into a system, users will forget them parse server provides a way to let them securely reset their password the password reset flow starts getting the user’s email address and calling the requestpasswordreset requestpasswordreset method from parse user parse user class this will attempt to match the given email with the user’s email or username field and send them a password reset email by doing this, you can opt to have users use their email as their username, or you can collect it separately and store it in the email field the flow for password reset is as follows user requests that their password be reset by typing in their email back4app sends an email to their address with a special password reset link user clicks on the reset link and is directed to a special back4app page to type in a new password user types in a new password their password has now been reset to a value they specify in this guide, you will learn how to use the flutter plugin for parse server to implement user reset password feature using the parseuser parseuser class for your flutter app goal build a reset password feature using parse for a flutter app prerequisites to complete this tutorial, you will need flutter version 2 2 x or later https //flutter dev/docs/get started/install android studio https //developer android com/studio or vs code installed (with plugins dart and flutter) a flutter app created in previous guide note follow the get current user on session complete the previous guide so ou can have a better understanding of the parseuser parseuser class a device (not simulator) running android or ios understanding reset password process to better understand reset password process, we will continue the development of the application started in the previous guide and implement the function we won’t explain the flutter application code once this guide’s primary focus is using the flutter with parse following the next steps, you will build a login e logout app at back4app database let’s get started! in the following steps, you will be able to build a reset password function in our application 1 open the login/logout/reset password app project open flutter project from the previous guide get current user on session https //www back4app com/docs/flutter/parse sdk/flutter current user%22 go to the main dart main dart file 2 code for reset password to start the password reset flow, we need the user’s email search for the function douserresetpassword douserresetpassword in the file main dart main dart replace the code inside douserresetpassword douserresetpassword with 1 final parseuser user = parseuser(null, null, controlleremail text trim()); 2 final parseresponse parseresponse = await user requestpasswordreset(); 3 if (parseresponse success) { 4 message showsuccess( 5 context context, 6 message 'password reset instructions have been sent to email!', 7 onpressed () { 8 navigator of(context) pop(); 9 }); 10 } else { 11 message showerror(context context, message parseresponse error! message); 12 } to build this function, follow these steps create a new parseuser parseuser class instance with the command parseuser(null, null, controlleremail text trim()); parseuser(null, null, controlleremail text trim()); the email field is required for the other fields you can use null call the user requestpasswordreset user requestpasswordreset function to send the recovery email the complete function should look like this 1 void douserresetpassword() async { 2 final parseuser user = parseuser(null, null, controlleremail text trim()); 3 final parseresponse parseresponse = await user requestpasswordreset(); 4 if (parseresponse success) { 5 message showsuccess( 6 context context, 7 message 'password reset instructions have been sent to email!', 8 onpressed () { 9 navigator of(context) pop(); 10 }); 11 } else { 12 message showerror(context context, message parseresponse error! message); 13 } 14 } to test it, click on the run run button in android studio/vscode click on reset password reset password button on the next screen enter the user’s email and click reset password reset password again it’s done! at the end of this guide, you can implement password reset function of your app using parse server core features through back4app!