@tomantransfers i have no clue where im messing up here ,
This is my code
Verification page (where link takes you to)
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!");
}
} );
} );
##Backend
import wixUsers from 'wix-users-backend';
export function doRegistration(email, password, firstName, lastName, companyName, emailVerified) {
// register the user
return wixUsers.register(email, password, {
"contactInfo": {
"firstName": firstName,
"lastName": lastName,
"companyName": companyName,
"emailVerified": emailVerified
}
} )
.then( (results) => {
// user is now registered and pending approval
// send a registration verification email
wixUsers.emailUser('verifyRegistration', results.user.id, {
"variables": {
"name": firstName,
"verifyLink": `mywebsitedomain/veripage?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};
} );
}
##reg form
import wixUsers from 'wix-users';
import {doRegistration} from 'backend/register';
import wixLocation from 'wix-location';
export function registerNow_click(event) {
let email = $w('#email').value;
let companyName = $w('#companyName').value; // the user's email
let password = $w('#password').value; // the user's password
let firstName = $w('#firstName').value; // the user's first name
let lastName = $w('#lastName').value; // the user's last name
let emailVerified = $w('#emailVerified').value; // Set email verfiy to false
doRegistration(email, password, firstName, lastName, companyName, emailVerified)
.then( () => {
console.log("Confirmation email sent.");
wixLocation.to('/exit');
} );
}
im a beginner when it comes to this so ignore my ignorance.
im able to register and the click the link but i dont get approved