fix(auth): strictly respect demo_access_enabled setting on login page and error redirects
This commit is contained in:
@@ -11,7 +11,7 @@ const isSecureCookie = (req) => {
|
|||||||
router.get('/login', async (req, res) => {
|
router.get('/login', async (req, res) => {
|
||||||
let providers = { local: true, google: false, moodle: false };
|
let providers = { local: true, google: false, moodle: false };
|
||||||
let google_client_id = '';
|
let google_client_id = '';
|
||||||
let demo_access_enabled = true;
|
let demo_access_enabled = false;
|
||||||
try {
|
try {
|
||||||
const resp = await apiClient.get('/auth/providers');
|
const resp = await apiClient.get('/auth/providers');
|
||||||
if (resp.data) {
|
if (resp.data) {
|
||||||
@@ -24,7 +24,7 @@ router.get('/login', async (req, res) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Fallback default
|
console.warn('Providers fetch notice in login:', e.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
res.render('auth/login', {
|
res.render('auth/login', {
|
||||||
@@ -58,14 +58,11 @@ router.post('/login', async (req, res) => {
|
|||||||
return res.redirect('/dashboard');
|
return res.redirect('/dashboard');
|
||||||
}
|
}
|
||||||
|
|
||||||
res.render('auth/login', { error: 'Autenticación fallida' });
|
return res.redirect('/auth/login?error=' + encodeURIComponent('Autenticación fallida'));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Login error:', error.response?.data || error.message);
|
console.error('Login error:', error.response?.data || error.message);
|
||||||
const errorMsg = error.response?.data?.message || 'Error en el servidor de autenticación';
|
const errorMsg = error.response?.data?.message || 'Credenciales de acceso incorrectas o cuenta inactiva.';
|
||||||
res.render('auth/login', {
|
return res.redirect('/auth/login?error=' + encodeURIComponent(errorMsg));
|
||||||
error: errorMsg,
|
|
||||||
providers: { local: true, google: false, moodle: false }
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -190,7 +190,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if demo_access_enabled is not defined or demo_access_enabled %}
|
{% if demo_access_enabled %}
|
||||||
<!-- Accesos Rápidos Institucionales (Demo) -->
|
<!-- Accesos Rápidos Institucionales (Demo) -->
|
||||||
<div class="p-3 bg-body-tertiary rounded-3 border mt-3">
|
<div class="p-3 bg-body-tertiary rounded-3 border mt-3">
|
||||||
<div class="d-flex justify-content-between align-items-center mb-2">
|
<div class="d-flex justify-content-between align-items-center mb-2">
|
||||||
|
|||||||
Reference in New Issue
Block a user