Good morning, I'm making a website that asks to login, and after this, it is redirected to another page if the user exists. This is done through Javascript queries to an API, where the user and password are searched and if it is correct, it takes us to another page with the content. This is done correctly, but the problem is that I can access that private page by writing it directly in the url, that is, I can access the content by typing link (being panelPrivate.html something that should only be accessible by a previous user login).
function login(){
usuario = $('#textDNI').val();
clave = $('#passWeb').val();
if($('#textDNI').val() == ''){
alert('Debe ingresar su DNI');
return false;
}
if($('#passWeb').val() == ''){
alert('Debe ingresar su contraseña');
return false;
}else{
var urlEnvio = 'ruta de la API'
var elementos = [];
axios.get(urlEnvio, {
params: {
user: usuario,
pass: clave
}
})
.then(response => {
elementos = response.data;
console.log(response.data);
console.log(response.status)
if (elementos.count == 0) {
alert('No existe el usuario en el sistema');
}else{
window.location.href = 'panelUsuario.html';
}
});
}
}
I would appreciate any help on this. Thank you very much in advance.