Confirmation/Verification email Question

Hi, Im trying to understand how confirmation/verification email works. So i follow this code posted by GOS .
https://www.wix.com/corvid/forum/main/comment/5c7bf11a440f0a03b5cf6704?fbclid=IwAR2D7_MQ84U-I3CXevnObV00sSFcM7j2RTsosS0MVq_4gpPVT9th0Jl8QFA

“The code is split between three locations:
A backend web module named register.jsw . - backend module (okay)
The page code for the page where users register. - SignUp page ( button click, okay)
The page code for the page where users confirm their registration. - new webpage?”

“/post-register” is a page where the 3rd code will be inserted?
I just need to add a new page named “post-register”?

Thank you in advance.

You can find this in the Wix API Reference here, it is the third example down in that section.
https://www.wix.com/corvid/reference/wix-users-backend.html#approveByToken

Your registration page.

/*********************************
 * client-side registration code *
 *********************************/
import wixUsersBackend from 'wix-users';
import {doRegistration} from 'backend/register';

export function button_click(event) {
  let email = // the user's email address
  let password = // the user's password
  let firstName = // the user's first name
  let lastName = // the user's last name

  doRegistration(email, password, firstName, lastName)
    .then( () => {
      console.log("Confirmation email sent.");
    } );
}

Your backend jsw file for it.

/*******************************
 * backend code - register.jsw *
 *******************************/
import wixUsersBackend from 'wix-users-backend';

export function doRegistration(email, password, firstName, lastName) {
  // register the user
  return wixUsersBackend.register(email, password, {
    "contactInfo": {
      "firstName": firstName,
      "lastName": lastName
    }
  } )
  .then( (results) => {
    // user is now registered and pending approval
    // send a registration verification email
    wixUsersBackend.emailUser('verifyRegistration', results.user.id, {
      "variables": {
        "name": firstName,
        "verifyLink": `http://yourdomain.com/post-register?token=${results.approvalToken}`
      }
    } );
  } );
}

export function doApproval(token) {
  // approve the user
  return wixUsersBackend.approveByToken(token)
  // user is now active, but not logged in
  // return the session token to log in the user client-side
    .then( (sessionToken) => {
      return {sessionToken, "approved": true};
    } )
    .catch( (error) => {
      return {"approved": false, "reason": error};
    } );
}

The page that new site members go to when they have registered using the email approval link (as in code shown as the post-register page).

Although it is easier to leave the page as it is called, you can call the page whatever you like, however it MUST MATCH in your url link in your code or it will not work.

/**************************************
 * client-side post-registration code *
 **************************************/
import wixLocation from 'wix-location';
import wixUsersBackend from 'wix-users';
import {doApproval} from 'backend/register';

$w.onReady( () => {
  // get the token from the URL
  let token = wixLocation.query.token;

  doApproval(token)
    .then( (result) => {
      if (result.approved){
        // log the user in
        wixUsersBackend.applySessionToken(result.sessionToken);
          console.log("Approved");
      }
      else {
        console.log("Not approved!");
      }
    } );
} );