Email Verification
11 min
user email verification for flutter introduction enabling email verification in an application’s settings allows the application to reserve part of its experience for users with confirmed email addresses email verification adds the \<font color="#2166ae">emailverified\</font> key to the \<font color="#2166ae">parseuser\</font> object when a \<font color="#2166ae">parseuser\</font> email is set or modified, \<font color="#2166ae">emailverified\</font> is set to \<font color="#2166ae">false\</font> parse then emails the user a link which will set \<font color="#2166ae">emailverified\</font> to \<font color="#2166ae">true\</font> there are three \<font color="#2166ae">emailverified\</font> states to consider true the user confirmed his or her email address by clicking on the link parse emailed them false at the time the \<font color="#2166ae">parseuser\</font> object was last fetched, the user had not confirmed his or her email address if \<font color="#2166ae">emailverified\</font> is \<font color="#2166ae">false\</font> if emailverified is false, consider calling \<font color="#2166ae">getupdateduser()\</font> on the parseuser missing the in this guide, you will learn how to set up a user email verification process to a user registration feature (sign up) you will create an app that includes user registration with email verification using parse server core features https //www back4app com/product/parse server through back4app you will use the same method you used to implement the user registration, but instead of redirecting the user to a logged screen, you will ask the user to verify their email to log in goal build a user verification email process 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 how to implement user password reset https //app archbee com/docs/ roxiyumxobue9i7uv49e/3uunuqp0k0awbtyuil4es 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 email verification function to better understand email verification function, 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 email verification function in app 1 enable email verification let’s now enable the email verification on back4app dashboard the email verification page has two properties \<font color="#2166ae">verify user emails\</font> and \<font color="#2166ae">prevent login if the email is not verified\</font> if you enable only the verify user emails option, the user will receive the verification email but will be able to log in and use the application normally if you also enable the prevent \<font color="#2166ae">login if email is not verified\</font> option, the user will only log in after concluding the email verification process go to your app at back4app website https //www back4app com/ and click on \<font color="#2166ae">server settings\</font> find the \<font color="#2166ae">verification emails card and click on\</font> settings` 3\ click on \<font color="#2166ae">verify user email\</font> and \<font color="#2166ae">prevent login if the email is not verified\</font> 4\ optional fill the empty fields and modify the ones that have already been filled based on your preferences 5\ click on the \<font color="#2166ae">save\</font> button 2 update the login/logout/reset password app open flutter project from the previous guide how to add user reset password to a flutter app https //www back4app com/docs/flutter/parse sdk/users/flutter reset password search for the function \<font color="#2166ae">douserregistration\</font> in the file \<font color="#2166ae">main dart\</font> after call function \<font color="#2166ae">user signup()\</font> ;, call the \<font color="#2166ae">user logout()\</font> function, to ensure that the user does not log in until the email is confirmed update the message informing the user to check the mailbox e redirect the user to home screen replace the code inside \<font color="#2166ae">douserregistration\</font> with 1 void douserregistration() async { 2 final username = controllerusername text trim(); 3 final email = controlleremail text trim(); 4 final password = controllerpassword text trim(); 5 6 final user = parseuser createuser(username, password, email); 7 8 var response = await user signup(); 9 10 if (response success) { 11 message showsuccess( 12 context context, 13 message 'user was successfully created! please verify your email before login', 14 onpressed () async { 15 navigator pop(context); 16 }); 17 } else { 18 message showerror(context context, message response error! message); 19 } 20 } note the code for signup function has been explained previously 3 test sign up to test it, click on the \<font color="#2166ae">run\</font> button in android studio/vscode perform the registration process, clicking in button \<font color="#2166ae">sign up\</font> after signup we will receieve an email like this after click in link to verify the email, the property will be setted to true in parse dashboard 4 log in to implement the log in with email verification, you have just to implement a parse user logins just as described on user login guide https //www back4app com/docs/flutter/parse sdk/users/flutter login if you have enabled the ‘prevent login if email is not verified’ option in step 2, you will get the following error if you try to login without verifying your email it’s done! at this stage, you can log in, sign up or log out of your app using email verification with parse server core features through back4app!