Well with everything that you have helped me I find it interesting, you will surely remember that you helped me develop this code to recognize a login for a specific time
import wixStorage from 'wix-storage';
import wixLocation from 'wix-location';
import wixData from 'wix-data';
import wixWindow from 'wix-window';
var onlineState
$w.onReady(() => {
setInterval(logOut, (1*1000*60)); // --> LOGOUT every 5min
$w("#button1").onClick(async () => {
//getting online-status...
onlineState = wixStorage.session.getItem("onlineState");
if(onlineState === "true") {
wixLocation.to("/principal")
}
else {
let email = $w("#email").value
let contrasena = $w("#contrasena").value
await checkLogin(email, contrasena)
}
})
/*onlineState = wixStorage.session.getItem("onlineState");
if(onlineState === "true") {
$w("#email").hide()
$w("#contrasena").hide()
} else{
$w("#email").show()
$w("#contrasena").show()
}*/
})
function logOut() {onlineState == "true";
//setting online-status...
wixStorage.session.setItem("onlineState", "false");
}
async function checkLogin(email, contrasena) {
wixData.query("logingers")
.eq("title", email)
.eq("contrasena", contrasena)
.find()
.then((res)=>{
if (res.items.length > 0) {//setting online-status...
wixStorage.session.setItem("onlineState", "true");
wixLocation.to("/principal")
} else {
//wixWindow.openLightbox('loginwarn');
console.error("Email/Contrasena wrong!")
}
});
}
Well, I have tried to do the following, while the session is active, disable the input of email “#email” and password “#password” so that only the send button “# button1” remains and after the time expires. the session show the inputs again to log in again
I have tried to implement this code snippet over and over again in a thousand ways and I have not been able to solve it
/*onlineState = wixStorage.session.getItem("onlineState");
if(onlineState === "true") {
$w("#email").hide()
$w("#contrasena").hide()
} else{
$w("#email").show()
$w("#contrasena").show()
}*/
I know that this could be solved in some way but I already tried and I can not, could you help me to achieve it please?