Add debug logging for markContactEmailsAsRead and remove password change restriction
This commit is contained in:
@@ -57,34 +57,3 @@ export const authenticate = async (req, res, next) => {
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Optional authentication - nepovinnné overenie
|
||||
* Ak je token poskytnutý, overí ho, ale nehodí error ak nie je
|
||||
*/
|
||||
export const optionalAuthenticate = async (req, res, next) => {
|
||||
try {
|
||||
let token = null;
|
||||
|
||||
const authHeader = req.headers.authorization;
|
||||
if (authHeader && authHeader.startsWith('Bearer ')) {
|
||||
token = authHeader.substring(7);
|
||||
}
|
||||
|
||||
if (!token && req.cookies && req.cookies.accessToken) {
|
||||
token = req.cookies.accessToken;
|
||||
}
|
||||
|
||||
if (token) {
|
||||
const decoded = verifyAccessToken(token);
|
||||
const user = await getUserById(decoded.id);
|
||||
req.user = user;
|
||||
req.userId = user.id;
|
||||
}
|
||||
|
||||
next();
|
||||
} catch (error) {
|
||||
// Ignoruj chyby, len pokračuj bez user objektu
|
||||
next();
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user