All checks were successful
Deploy to production / deploy (push) Successful in 1m55s
- Added user blocking checks in authentication and reporting processes, returning appropriate error responses. - Expanded moderation report functionality to include new target types and optional fields for reports. - Implemented a new API endpoint to retrieve the count of open moderation reports. - Enhanced frontend components to allow users to report profiles, images, and guestbook entries, with corresponding UI updates. - Updated internationalization files to include new strings for reporting features in both German and English.
26 lines
892 B
JavaScript
26 lines
892 B
JavaScript
import User from '../models/community/user.js';
|
|
import { updateUserTimestamp } from '../utils/redis.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: { hashedId: userId, authCode } });
|
|
if (!user) {
|
|
return res.status(401).json({ error: 'Unauthorized: Invalid credentials' });
|
|
}
|
|
if (!user.active) {
|
|
return res.status(403).json({ error: 'Unauthorized: User blocked' });
|
|
}
|
|
try {
|
|
await updateUserTimestamp(user.id);
|
|
} catch (error) {
|
|
console.error('Fehler beim Aktualisieren des Zeitstempels:', error);
|
|
}
|
|
next();
|
|
};
|
|
|
|
// Default export für Kompatibilität
|
|
export default { authenticate };
|