on BACKEND i got:
export function doRegistration(email, password, options) {
return authentication
.register(email, password, options)
.then((registrationResult) => {
// send email with verification
myEmailContactFunction('registration', registrationResult.member._id, {
"variables": {
"email": email,
"verifyLink": `http://rebrandy.net/verification-page?token=${registrationResult.approvalToken}`,
}
});
return registrationResult;
})
.catch((error) => {
console.error(error);
});
}
on FRONTEND:
import { doRegistration } from 'backend/register';
export function button_click(event) {
const email = $w('#email').value; // the user's email address
const password = $w('#password').value; // the user's password
doRegistration (email, password)
.then(() => {
console.log("Confirmation email sent.");
} );
}
}
on logs i receive:
“server responded with - {“message”:“Didn’t receive token”,“details”:{“applicationError”:{“code”:”-19971"}}} (403)"
Problem since 15.12.24
1 Like
I am experiencing the same issue. My registration code has been working flawlessly for over two years, but it suddenly stopped functioning a few days ago. I have already reached out to Wix Velo support for assistance.
1 Like
Hi!
This issue has been resolved by moving to a new part of the API.
https://dev.wix.com/docs/velo/api-reference/wix-members-backend/authentication/approve-by-token
Check the example “Register a user sending an email for confirmation”
Create register.web.js on backend and fill it with code from example. That’s the key.
/*******************************
* Backend code - register.web.js *
*******************************/
import { Permissions, webMethod } from "wix-web-module";
import { authentication } from "wix-members-backend";
import { triggeredEmails } from "wix-crm-backend";
export const doRegistration = webMethod(
Permissions.Anyone,
async (email, password, firstName, lastName) => {
const registrationOptions = {
contactInfo: {
firstName: firstName,
lastName: lastName,
},
};
const registration = await authentication.register(
email,
password,
registrationOptions,
);
console.log("Member is now registered with the site and pending approval");
const emailOptions = {
variables: {
name: firstName,
verifyLink: `http://yourdomain.com/post-register?token=${registration.approvalToken}`,
},
};
triggeredEmails.emailMember(
"verifyRegistration",
registration.member.id,
emailOptions,
);
console.log("Confirmation email sent");
},
);
export const doApproval = webMethod(Permissions.Anyone, async (token) => {
try {
const sessionToken = await authentication.approveByToken(token);
console.log("Member approved");
return {
approved: true,
sessionToken: sessionToken,
};
} catch (error) {
console.log("Member not approved");
return {
approved: false,
reason: error,
};
}
});
/****************************
* Page code - registration *
****************************/
import { doRegistration } from "backend/register.web";
// ...
const email = $w("#email").value;
const password = $w("#password").value;
const firstName = $w("#firstName").value;
const lastName = $w("#lastName").value;
doRegistration(email, password, firstName, lastName).then(() => {
console.log("Confirmation email sent.");
});
/*********************************
* Page code - post-registration *
*********************************/
import wixLocationFrontend from "wix-location-frontend";
import { authentication } from "wix-members-frontend";
import { doApproval } from "backend/register.web";
$w.onReady(async () => {
const token = wixLocationFrontend.query.token;
const approval = await doApproval(token);
if (approval.approved === true) {
authentication.applySessionToken(approval.sessionToken);
console.log("Member approved & logged in");
} else {
console.log("Member not approved");
}
});
We are running into the same issue with a registration system that was working perfectly but isn’t working at all anymore even when using the code in the approve-by-token docs.
We do not want the user to be authenticated via their own email, and want to authenticate manually in the site backend. Our code is below:
We are only getting a red error: “Didn’t receive token” when testing it.
import { Permissions, webMethod } from "wix-web-module";
import { authentication } from "wix-members-backend";
export const doRegistration = webMethod(
Permissions.Anyone,
async (email, password, firstName, lastName) => {
const registrationOptions = {
contactInfo: {
firstName: firstName,
lastName: lastName,
},
};
await authentication.register(
email,
password,
registrationOptions,
);
console.log("Member is now registered with the site and pending approval");
},
);
Any help would be much appreciated!
Yes, that error is back.
Thinking.
So,
first, you need to set up login and registration settings as follows



next
https://dev.wix.com/docs/velo/api-reference/wix-members-backend/authentication/approve-by-token
Check the example “Register a user sending an email for confirmation”
Create register.web.js on backend and fill it with code from example.



last
In order for the user to receive an email with a verification link, it is necessary to use only the emailMember() function from the backend
https://dev.wix.com/docs/velo/api-reference/wix-crm-backend/triggered-emails/email-member
And now it’s working.
1 Like
i had this same issue and it was because i had the recaptcha settings set to “prompt on suspected bots” while my custom velo sign up form did not have a recaptcha element so it was randomly failing auth.
6 Likes
This was my issue as well. Custom VELO form and the Re-Captcha option was set to “Suspected bots”. Once that was de-activated, it worked again. Thank you WIX for making our life easy!
My website is also now broken due to this change. All my new users are getting a -19997 error code since the beginning of the year.
I can’t use the approve-by-token() because the program is trying to register the new user rather than approve them - plus I can’t get the token in the first place. So the solution above is not helpful.
My use case is that when the user requests access to the site, the velo code checks against another system (Salesforce) to see if they are a valid user and if so, uses the authentication.register() to create the user (contact) with the status automatically set to approved. They can then be logged into the website through the front end using authentication.applySessionToken().
Is there any fix to the authentication.register() problem?