Custom Log In Code Help

Hi All,
I have been trying to figure out a complete approach to making my custom log in and registrations work flawlessly. I have managed to make them work as intended except for the following:

  1. Log In- How are you guys adding a login error message for when the email or password is not correct or doesn’t match?

  2. Log In - How are you adding a forgot password prompt? I am using the example from the reference site but i cant get it to work.

  3. Registration - How are you adding a duplicate user or “email address already used” error message?

I think I am missing a basic key to making these work?

Here is my current login code, Where and what are you using for the error message and forgot password?

import wixUsers from ‘wix-users’;
import wixLocation from ‘wix-location’;
$w.onReady( function (){
$w(‘#button2’).onClick( function (){
let email = $w(‘#emailinput’).value;
let password = $w(‘#passwordinput’).value;
wixUsers.login(email, password)
console.log(“User is logged in”); } )
. catch ( (err) => { console.log(err);

Here is my registration code, Where and what would you add for a duplicate account error?

import wixUsers from ‘wix-users’;

$w.onReady( function () {
$w(‘#button19’).onClick( () => {

// register as member using form data
wixUsers.register($w(‘#email’).value, $w(‘#password’).value, {
“contactInfo”: {
“firstName”: $w(‘#firstName’).value,
“lastName”: $w(‘#lastName’).value,
“emails”: [$w(‘#email’).value],
“phones”: [$w(‘#phone’).value],
“fax”: ($w(‘#fax’).value),
“address”: ($w(‘#address’).value),
“city”: ($w(‘#city’).value),
“zip”: ($w(‘#zip’).value),
“state”: ($w(‘#state’).value),
“title”: ($w(‘#title’).value),
“company”: ($w(‘#company’).value),
“website”: ($w(‘#website’).value),
“founded”: ($w(‘#year’).value),
“employees”: ($w(‘#employees’).value),
“routes”: ($w(‘#routes’).value),
“heard”: ($w(‘#heard’).value)



import wixLocation from ‘wix-location’;

$w.onReady( function () {
$w(‘#button19’).onClick( () => {“/plans-pricing”);

Any help would be greatly appreciated.

1 Like

Hi, I attempted with your reg and login code, but I get a 500 server error. Could you please advise how you are deploying this code in Wix? Are you using dynamic pages, or just a normal page and dataset

@Wix Trix Designs

Wix crm does not prevent duplicate email address being registered so to verify an email has not been previousy registered you have to create a seperate database containing all previous member email addresses (make sure you format them all the same i.e. all lower case). Then query that database to see if the new member email address has already been used, something like this…

wixData.query(“emailDatabase”) .eq(“userEmail”, $w(" #SignupEmailInput ").value) .limit(1) .find() .then( (results) => { let numberOfResults = results.totalCount; console.log(numberOfResults)

1 Like

For forgot password just run the below code with an onClick on some text or button to load the generic forgot password screen, note wix does not allow customization of the forgot password page, also note the user will receive an email directly from wix with a big wix logo when they reset their password…

import wixUsers from ‘wix-users’;