Flutter
...
Authentication
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 emailverified emailverified key to the parseuser parseuser object when a parseuser parseuser email is set or modified, emailverified emailverified is set to false false parse then emails the user a link which will set emailverified emailverified to true true there are three emailverified emailverified 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 parseuser parseuser object was last fetched, the user had not confirmed his or her email address if emailverified emailverified is false false if emailverified is false, consider calling getupdateduser() getupdateduser() 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 (with plugins dart and flutter) a flutter app created in previous guide note follow the how to implement user password reset 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 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 verify user emails verify user emails and prevent login if the email is not verified prevent login if the email is not verified 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 login if email is not verified login if email is not verified 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 server settings server settings find the verification emails card and click on verification emails card and click on settings` 3\ click on verify user email verify user email and prevent login if the email is not verified prevent login if the email is not verified 4\ optional fill the empty fields and modify the ones that have already been filled based on your preferences 5\ click on the save save 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 douserregistration douserregistration in the file main dart main dart after call function user signup() user signup() ;, call the user logout() user logout() 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 douserregistration douserregistration 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 run run button in android studio/vscode perform the registration process, clicking in button sign up sign up 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!