Login Page

Hello! I have created a login page that has only two fields: username and password. When a user hits the login button, the code analyzes whether the user exists in a collection I named USERS and if the username exists, then it queries for the password to the same collection. I am not using neither wixCRM, nor wixUsers API’s. Here is the code:

wixData.query(“USERS”).eq(“correo_e”, userCorreoElectronico).find().then((results) => {
resultCount = results.totalCount;

if (resultCount) { // The user is in the collection USERS
userType = results.items[0].tipo;
userID = results.items[0]._id;
userSecuenciaCaracteresDB = results.items[0].secuencia_caracteres;

                // Verify the password 
                if  (passwordDB === userPassword) { 
                      // valid user 
                }  **else**  { // Wrong password. 
                    $w("#textErrors").show(); 
                    $w("#textErrors").text = "Usuario o contraseña incorrectos."; 
                } 

} else { // El usuario no está en la base de datos.
$w(“#textErrors”).show();
$w(“#textErrors”).text = “Usuario o contraseña incorrectos.”;
}
})
. catch ((err) => {
let errorMsg = err;
});

Attached is a screen shot of the login page I’ve created.


The issue is that when the user hits the “Begin Sesion/Iniciar Sesión” button, Wix launches the login page of the Wix Members Login. Here is the screenshot:

Technically, my login page is a simple form build with a couple of inputText boxes and a submit button to a collection. I don’t know why Wix launched the Wix Login Members page.

Your help is most welcome!

Thank you!

Marco

2 Likes

Hello Marco

By default, that button links to the Wix members login/signup page.
To have it link to a specific page you would need to delete that button and replace it with a new one, add an onClick() event to it and have it redirect to your custom login/signup page. You can do this using the wixLocation.to() function and adding your Url in the parameters

More on that - here

A side note: It is not very good to store passwords as plain text in your database, or any user information for that matter. If possible try using the Wix Members feature as it is much more secure and reliable.

Best,
Majd