Custom lightbox login that mis-functions like registration. Why?

I created a custom lightbox login for members, and I used the login() code from https://www.wix.com/corvid/reference/wix-users/login . However, when I click the submit button, instead of the login function checking against my profile database for email and password, it creates a new profile.

I want the code to check against my profile database → logs in users → redirect to another page if successful. Help! And thank you!

import wixUsers from ‘wix-users’ ;
import wixLocation from ‘wix-location’ ;
import wixWindow from ‘wix-window’ ;

export function loginButton_onclick(event) {

let email = $w( “#email” ).value;
let password = $w( “#password” ).value;

wixUsers.login(email, password)
.then( () => {
console.log( “User is logged in” );
wixWindow.lightbox.close();
wixLocation.to( ‘/member’ );
} )
. catch ( (err) => {
console.log(err);
} );
}

Hello Wendy, take a look at this site here…

https://russian-dima.wixsite.com/meinewebsite

perhaps you will find some answers there for your issues. :wink:

@russian-dima Thanks for the link, but I did not find the code to fix this issue.

@wendymfoo
You will find for every of your issues an example, already disscussed on my site.
User the example and the corresponding forum-posts. Read all the stuff with all the issues and solutions, then you will be able to solve your issue.

@russian-dima I read through your site and still couldn’t find the solution that will solve my issues. Thanks anyway for your help.

You have incorrectly connected the Login button to a dataset (and a Submit action), while also connecting the Login button to a loginButton_onclick() event handler.

You should also check the dataset to see if it is set to the correct item.