Initial Commit

This commit is contained in:
HPL-JesusCastro
2026-05-26 16:04:14 +08:00
commit 5d6f228224
62 changed files with 10152 additions and 0 deletions

25
server/routes/auth.js Normal file
View File

@@ -0,0 +1,25 @@
const express = require('express');
const crypto = require('crypto');
const router = express.Router();
function makeToken(password) {
return crypto.createHmac('sha256', password).update('showcase-session').digest('hex');
}
router.post('/login', (req, res) => {
const { password } = req.body;
const expected = process.env.SHOWCASE_PASSWORD;
if (!expected) {
return res.status(500).json({ error: 'Server not configured' });
}
if (!password || password !== expected) {
return res.status(401).json({ error: 'Invalid password' });
}
res.json({ token: makeToken(expected) });
});
module.exports = { router, makeToken };