Create An "InCorrect Password" Error Message In My Custom Login Code

Question:
Hello, I am working in Wix Editor Velo and need to create an “InCorrect Password” Error Message for my custom login page, if a user types in a Wrong Password for their account. Below is my code. Any suggestions would be appreciated as to what I should add in

Product:
Wix Editor, Velo

Code:

import wixUsers from 'wix-users';
import wixLocation from 'wix-location';
 
$w.onReady(function(){  
    $w('#loginNow').onClick(function (){    
        let email = $w('#loginEmail').value;    
        let password = $w('#loginPassword').value;  
        wixUsers.login(email,password)  
        .then(()=>{
            wixLocation.to('/members');   
            })
        })

Wix users is deprecated, I’d recommend you use Wix Members instead

import wixLocationFrontend from 'wix-location-frontend';
import { authentication } from 'wix-members-frontend';

$w.onReady(function () {
    $w('#loginNow').onClick(function () {

        userEmail = $w('#loginEmail').value;
        userPassword = $w('#loginPassword').value;

        authentication.login(userEmail, userPassword)
            .then(() => {

                $w('#textStatus').text = "Logged In successfully!"
             
                    wixLocationFrontend.to('/members');
   
            })
            .catch((error) => {

                $w('#textStatus').text = "ERROR: Invalid login credentials";

            });
    });
});

Thank you so much!! I greatly appreciate it

1 Like