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 \<font color="#2166ae">requestpasswordreset\</font> method from \<font color="#2166ae">parse user\</font> 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 \<font color="#2166ae">parseuser\</font> 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 https //code visualstudio com/ (with plugins https //docs flutter dev/get started/editor dart and flutter) a flutter app created in previous guide note follow the get current user https //app archbee com/docs/ roxiyumxobue9i7uv49e/hzburmiwcukmjmsxudirt on session complete the previous guide so ou can have a better understanding of the \<font color="#2166ae">parseuser\</font> 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 \<font color="#2166ae">main dart\</font> file 2 code for reset password to start the password reset flow, we need the user’s email search for the function \<font color="#2166ae">douserresetpassword\</font> in the file \<font color="#2166ae">main dart\</font> replace the code inside \<font color="#2166ae">douserresetpassword\</font> 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 \<font color="#2166ae">parseuser\</font> class instance with the command \<font color="#2166ae">parseuser(null, null, controlleremail text trim());\</font> the email field is required for the other fields you can use null call the \<font color="#2166ae">user requestpasswordreset\</font> 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 \<font color="#2166ae">run\</font> button in android studio/vscode click on \<font color="#2166ae">reset password\</font> button on the next screen enter the user’s email and click \<font color="#2166ae">reset password\</font> 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!