Implement server-side authentication and update login UI texts

This commit is contained in:
2025-01-24 21:54:05 +01:00
parent 1edcefbd64
commit da2f568acf
4 changed files with 44 additions and 13 deletions

17
routes/auth.js Normal file
View File

@@ -0,0 +1,17 @@
const express = require('express');
const basicAuth = require('basic-auth');
const router = express.Router();
router.post('/login', (req, res) => {
const user = basicAuth(req);
const username = process.env.AUTH_USERNAME;
const password = process.env.AUTH_PASSWORD;
if (user && user.name === username && user.pass === password) {
res.status(200).send('Login successful');
} else {
res.status(401).send('Authentication required');
}
});
module.exports = router;