I have a JavaScript project that consumes an API which sends a specific responseCode and returns the role, according to that role, it is redirected to the page that the user should see, but I need that when placing the URL it does not allow him to see unless logged in, if not logged in, return to login.
if (code == 0) {
console.log('Usuario existe con rol: ' + rol, ' El mensaje del API fue: ' + message);
if (rol == 'Administrador') {
window.location.href = 'support/management/dashboard.html';
} else {
window.location.href = 'support/user/home.html?auth=true';
}
} else {
console.log('No permisos');
Swal.fire({
icon: 'error',
title: 'Oops...',
text: 'Usuario y/o Contraseña Incorrecto, verifique.'
});
}
This would be basic JavaScript logic, and I'd like any page other than index.html not to be accessible unless logged in.