Refactor auth.authentify.

We now get the user's details directly from the JWT token.
This commit is contained in:
D. Berge
2025-07-24 19:15:36 +02:00
parent f5441d186f
commit b3e27ed1b9

View File

@@ -78,11 +78,10 @@ async function auth (req, res, next) {
if (req.user.exp) {
const ttl = req.user.exp - Date.now()/1000;
if (ttl < cfg.jwt.options.expiresIn/2) {
const credentials = cfg._("global.users.login.user").find(i => i.name == req.user.name && i.role == req.user.role);
const credentials = await user.get(req.user.id);
if (credentials) {
// Refresh token
payload = Object.assign({}, credentials);
delete payload.hash;
jwt.issue(Object.assign({}, credentials), req, res);
}
}