Building a Custom Login Page

Hello, I am building a login lightbox that connects to a dynamic page to display client information that they will be able to read and update. I have my sign-in lightbox and its code, the members’ database, and the dynamic page with the dataset connected to the members’ database. I’ve also enabled custom site registration for the login page.

When I test the login lightbox, all it does is expand the error message, which I do want if there’s an error, but I’m not sure why there is an error and how I can fix this. Am I missing something? Here’s what I have so far. Any help would be amazing.

Also, the event listener is connected to the click event function. This can be seen in the dialog box on the right-hand side of the screen.

import wixUsers from 'wix-users';
import wixLocation from 'wix-location';
import wixWindow from 'wix-window';

$w.onReady(function () {
    $w('#forgotPassword').onClick( (event) => {
        wixUsers.promptForgotPassword()
        .then( () => {

        })
        .catch( (err) => {
 let errorMsg = err;

        });

    });

});

export function loginNow_click_1(event) {
 let email = ("#loginEmail").value;
 let password = ("#loginPassword").value;
 //$w('#loginPassword').inputType = 'password';

    wixUsers.login(email, password)
    .then( () => {
        console.log("User is logged in");
        wixLocation.to("/members/update/${wixUsers.currentUser.id}");
    })
    .catch( (err) => {
        console.log(err);
        $w("#errorMessage").expand();

    });

}

I think I know why I am getting just the error message. I think I need to query the database and then search to see if the member/email exists. Then if not create a new existing member but I’m not exactly sure how exactly to structure my code from up above with this.

I’m not so sure what the ‘loginEmail’ parameter refers to either.

import wixUsers from 'wix-users';
import wixData from 'wix-data';

$w.onReady(function () {
	wixUsers.currentUser.getEmail().then((email) => {
		return wixData.query('Members/PrivateMembersData')
			.eq('loginEmail', email)
			.find()
			.then(result => {
				if (result.totalCount === 0) {
					//New user
				} else {
					//Existing user
				}

			});
	});
});