Please help me

I’m trying to make a login form by filtering the database with the user email and password. I’m not a programmer so I’m trying my best. In the preview mode the code runs with no problem but when I make it live the code won’t work. I don’t know what’s the problem. Please help me find the solution.

Here is my piece of code.

import wixData from ‘wix-data’;
import wixLocation from ‘wix-location’;

$w.onReady(function () {
//TODO: write your page related code here…
});
let validationMessage = ’ ';
function usersLogin()
{
let userId;
let userEmail;
let userPassword;

wixData.query("Employee") 
    .eq('email', $w('#inputEmail').value)         
    .eq('password', $w('#inputPassword').value) 
    .find()     
    .then((results) => {          
        if (results.items.length !== 0) { 
            wixLocation.to("/login-employee"); 
           	//wixLocation.to("http://www.google.com/"); 
            
            $w('#validationMessages').collapse(); 
            //update buttons accordingly 
            $w('#button9').label = 'Logout'; 
        } 
        else 
        {            
            validationMessage += 'Invalid email or password\n '; 
            $w('#validationMessages').text = validationMessage; 
            $w('#validationMessages').expand(); 
        } 
  } ) 
  .catch( (err) => { 
    console.log(err); 
  } ) 

}

export function buttonLogin_click(event, $w) {
//Add your code for this event here:
validationMessage = ’ ‘;
$w(’#validationMessages’).text = validationMessage;
$w(‘#validationMessages’).collapse();

if (!($w('#inputEmail').valid && $w('#inputPassword').valid))  
{ 
    if (!$w('#inputEmail').valid) 
         validationMessage += 'Please enter your email\n';                            

    if (!$w('#inputPassword').valid)		 
        validationMessage += 'Please enter your password\n';   

    $w('#validationMessages').text = validationMessage; 
    $w('#validationMessages').expand();            
}     
else 
{ 
    usersLogin();             
} 

}
Thanks a lot guys.

Make sure you sync the Sandbox database with the Live database:


I hope this helps,

Yisrael

Hi Yisrael. Yes I had already synced it between the sandbox and live database but nothing happened. :frowning:

Please post the URL of your site. Only authorized Wix personnel can get access to your site in the editor.

What is it not doing when in Live mode?

It’s in the login page. https://trivellaid.wixsite.com/trivella/login

I would highly recommend redoing your login procedure. Your current database has unencrypted passwords which is definitely a no-no. You should use the wix-user API for enhanced security.

Meanwhile, what is it not doing when in Live? What is it supposed to do?

And you really, really should change your login mechanism. The wix-code API will take care of with a much higher level of security and will release you from the headache of handling the login.

I want to make 2 steps of login. I also made another login page (login-employee) with wix-user API and in order to access that page (login-employee) they must login first from the page I custom made (login).
The login button is supposed to execute the query to find the email and password in database that match with user input. If it returns a result then it should direct user to the login-employee page.
But in live mode, the login button in login page won’t execute the code which works just fine in preview mode when I click it.

Is there a way to disable sign up on wix user prompt login?

Thank you.