Email Verification Error

Hi everyone hope you all are fine please Help me out I am working on verification email through custom sign up in lighbox when I entered data in lightbox and click submit a Lightbox must diasappear and opens a new lightbox for “thanks for registration please verify email” but a new lighbox doesnot appear and email is sent to new member but then click on link to access the site after verification the site is not opening please help me out I think there is an error in verifylink please have a look I have highlight verifylink in code if there is an another error do tell me I have shared a whole code please check and this is the link. I got on mail for verification.
https://metingoek.wixsite.com/turicum/post-register?&token=JWS.eyJraWQiOiJSc012MmV3MiIsImFsZyI6IkhTMjU2In0.eyJkYXRhIjoie1wiaWRcIjpcIjFhZjUzYWQzLWQ5OGUtNDA2NS1iYjE1LTY2MTk1MGZkYzFiNVwiLFwiY29sbGVjdGlvbklkXCI6XCI5NmQxY2FmZS1lODE3LTRhOTAtYWE4MS1jNzliNDIxNTAzOWFcIn0iLCJpYXQiOjE1NzUzOTY0NzYsImV4cCI6MTU3NTM5Njc3Nn0.PXWyzNMveVxP1easVDTYlnWWpp1Y0DIpZE7146ovvIQ
and I want this link in the email ( https://metingoek.wixsite.com/turicum ) so user click on this and enter in site please help thanks :slight_smile:

“BACKEND CODE JSW”
import wixUsers from ‘wix-users-backend’;
export function doRegistration(Name, SurName, UserName, Email, Password, ConfirmPassword) {
return wixUsers.register(Email, Password, {
“contactInfo”: {
“Name” :Name,
“SurName” :SurName,
“UserName”: UserName,
“ConfirmPassword” : ConfirmPassword
}
} )
.then( (results) => {
// user is now registered and pending approval
// send a registration verification email
wixUsers.emailUser(‘RjUOsbU’, results.user.id, {
“variables”: {
“Name”: Name,
“verifyLink”: 'https://metingoek.wixsite.com/turicum/post-register?&token='+results.approvalToken
}
} );
} );
}
export function doApproval(token) {
// approve the user
return wixUsers.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};
} );
}
“FRONTEND CODE”
import wixUsers from ‘wix-users’;
import wixLocation from ‘wix-location’;
import wixWindow from ‘wix-window’;
import {doRegistration} from ‘backend/register’;
export function button8_click(event) {
let Name = $w(‘#input10’).value;
let SurName = $w(‘#input12’).value;
let UserName = $w(‘#input13’).value;
let Email = $w(‘#input14’).value;
let Password = $w(‘#input15’).value;
let ConfirmPassword = $w(‘#input16’).value;
doRegistration(Name, SurName, UserName, Email, Password, ConfirmPassword)
.then( () => {
console.log(“Confirmation email sent.”);
} );
}

Your code is unreadable. Please use paragraphs to format your questions and use the code block for the code.

As Shan says above, put your code in the code block and split up your original question so that it it is much easier to read and understand.

As for the issue, it looks like you are simply going off of the ‘Register a user sending an email for confirmation’ example from within the Wix Users Backend API section.
https://www.wix.com/corvid/reference/wix-users-backend.html#register

This example demonstrates a common email verification flow. A user is initially registered but not yet approved. At registration, a verification email is sent with a link to a verification page. When a user goes to the verification page, the approval is granted and the user is logged into the site.

The code is split between three locations:

  • A backend web module named register.jsw .

  • The page code for the page where users register.

  • The page code for the page where users confirm their registration.

So basically you would have the code in your backend jsw file.

/*******************************
* backend code - register.jsw *
*******************************/

import wixUsers from 'wix-users-backend';

export function doRegistration(email, password, firstName, lastName) {
// register the user
return wixUsers.register(email, password, {
"contactInfo": {
"firstName": firstName,
"lastName": lastName
}
} )
.then( (results) => {
// user is now registered and pending approval
// send a registration verification email
wixUsers.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 wixUsers.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 code on your registration page

/*********************************
* client-side registration code *
*********************************/

import wixUsers 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.");
} );
}

Finally, the code for your post registration page.

/**************************************
* client-side post-registration code *
**************************************/

import wixLocation from 'wix-location';
import wixUsers 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
wixUsers.applySessionToken(result.sessionToken);
console.log("Approved");
}
else {
console.log("Not approved!");
}
} );
} );

For you wanting to have the lightbox close and then open up another lightbox, then all you need to do is to add the code something like this:

wixWindow.lightbox.close();
wixWindow.openLightbox("YourLightbox");

Also, as for your verify link, check the code example against yours.

Code Example:

"verifyLink": `http://yourdomain.com/post-register?token=${results.approvalToken}`

Your Code:

"verifyLink": 'https://metingoek.wixsite.com/turicum/post-register?&token='+results.approvalToken

Finally, make sure that all your field names/field keys match up with your datasets own field names/field keys as not all of them will be capitalised at the start.

@ givemeawhisky Is domain needed for email notification because right now client dont have domain so domain needed for this ?

“verifyLink”: http:// **yourdomain.com** /post-register?token=${results.approvalToken}

I am guessing that as it states yourdomain.com in the verify link that it might be a good idea to have your own domain.

You can see if it will work with the free Wix site as stated in the Wix support page linked below, although having your own actual domain is always going to be the best option.
https://support.wix.com/en/article/about-domains

thanks buddy