Good morning, I have a small form for a login which is connected to a collection of BD and works perfectly which I show code, in my collection, in addition to having the fields for access that are email and password, I have fields of name and grade of the users, what I am looking for is the following, if the user I entered is called “Juan” with a “Doctor” degree, I want him to show me a personalized message such as the following "Welcome
Name: Juan
Degree: Doctor "
I currently have a welcome message but I would like it in a personalized way for each user according to the one entered, how can I get the users to recognize me and show me the message?
import wixStorage from 'wix-storage';
import wixLocation from 'wix-location';
import wixData from 'wix-data';
import wixWindow from 'wix-window';
var onlineState
setInterval(logOut, (1*1000*60));
$w.onReady(() => {
onlineState = wixStorage.session.getItem("onlineState");
if(onlineState === "true") {
$w("#email").hide()
$w("#contrasena").hide()
$w("#sesionactiva").show()
$w("#ingresar").hide()
}
$w("#ingresar").onClick(async () => {
//obtener estado en linea...
if(onlineState === "true") {
wixLocation.to("/eventos")
}
else {
let email = $w("#email").value
let contrasena = $w("#contrasena").value
await checkLogin(email, contrasena)
}
})
$w("#contrasena").onKeyPress(async(event) => {
if (event.key === "Enter") {
let email = $w("#email").value;
let contrasena = $w("#contrasena").value;
await checkLogin(email,contrasena);
}
})
})
function logOut() {onlineState === "true";
//configuracion de estado en linea...
wixStorage.session.setItem("onlineState", "false");
$w("#email").show()
$w("#contrasena").show()
$w("#ingresar").show()
$w("#sesionactiva").hide()
}
async function checkLogin(email, contrasena) {
wixData.query("logingers")
.eq("title", email)
.eq("contrasena", contrasena)
.find()
.then((res)=>{
if (res.items.length > 0) {//obtener estado en linea...
wixStorage.session.setItem("onlineState", "true");
wixLocation.to("/eventos")
} else {
wixWindow.openLightbox('loginwarn');
}
});
}