En-/decryption fixed
This commit is contained in:
16
backend/middleware/authMiddleware.js
Normal file
16
backend/middleware/authMiddleware.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import User from '../models/community/user.js';
|
||||
|
||||
export const authenticate = async (req, res, next) => {
|
||||
const userId = req.headers.userid;
|
||||
const authCode = req.headers.authcode;
|
||||
if (!userId || !authCode) {
|
||||
return res.status(401).json({ error: 'Unauthorized: Missing credentials' });
|
||||
}
|
||||
|
||||
const user = await User.findOne({ where: { hashedId: userId, authCode } });
|
||||
if (!user) {
|
||||
return res.status(401).json({ error: 'Unauthorized: Invalid credentials' });
|
||||
}
|
||||
|
||||
next();
|
||||
};
|
||||
Reference in New Issue
Block a user