fix: /me returns guest user when AUTH_ENABLED is false so auth-guard never fires on dev
This commit is contained in:
parent
4f649b41a9
commit
cb63e4743d
1 changed files with 6 additions and 0 deletions
|
|
@ -74,6 +74,12 @@ router.post('/logout', (req, res, next) => {
|
||||||
// GET /me
|
// GET /me
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
router.get('/me', async (req, res) => {
|
router.get('/me', async (req, res) => {
|
||||||
|
// When auth is disabled return a synthetic guest/admin user so the frontend
|
||||||
|
// auth-guard never receives a 401 and never redirects to login.html.
|
||||||
|
if (process.env.AUTH_ENABLED !== 'true') {
|
||||||
|
return res.json({ id: null, username: 'admin', display_name: 'Admin', role: 'admin' });
|
||||||
|
}
|
||||||
|
|
||||||
if (!req.session || !req.session.userId) {
|
if (!req.session || !req.session.userId) {
|
||||||
return res.status(401).json({ error: 'Not authenticated' });
|
return res.status(401).json({ error: 'Not authenticated' });
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue