As it states on the page:
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 firstly, you will use the page code for the page where users register (which in your case is your lightbox):
/*********************************
* 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.");
} );
}
Secondly, this will then take the necessary and push it through the backend register jsw:
/*******************************
* 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};
} );
}
With this line of code then directing it to the confirmnation page:
"verifyLink": `http://yourdomain.com/post-register?token=${results.approvalToken}`
Then your user will automatically be directed and be on your confirmation 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!");
}
} );
} );
From here the user is logged into your site, however you will need to add your own links from the page which the user can navigate from.
You can either just leave your page as it is and simply let the now logged in user go and use your header with your menu on it.
Or you could setup a couple of buttons or something that is set in the code to only be shown when the user is logged in and if not approved then the buttons are still hidden.