Initial commit

This commit is contained in:
Torsten Schulz (notebook)
2024-08-16 16:34:23 +02:00
commit 31ca0979ce
4216 changed files with 499206 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
import User from '../models/User.js';
export const authenticate = async (req, res, next) => {
const { userid: userId, authcode: authCode } = req.headers;
if (!userId || !authCode) {
return res.status(401).json({ error: 'Unauthorized: Missing credentials' });
}
const user = await User.findOne({ where: { email: userId, hashedId: authCode } });
if (!user) {
return res.status(401).json({ error: 'Unauthorized: Invalid credentials' });
}
next();
};