mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 07:07:07 +00:00
Fix JWT renewal over websocket
This commit is contained in:
@@ -16,10 +16,10 @@ function start (server, pingInterval=30000) {
|
||||
try {
|
||||
const payload = JSON.parse(message);
|
||||
if (payload?.jwt) {
|
||||
// console.log("Refresh JWT token", payload);
|
||||
const decoded = jwt.checkValidCredentials({jwt: payload.jwt});
|
||||
jwt.checkValidCredentials({jwt: payload.jwt}).then( decoded => {
|
||||
// console.log("Decoded", decoded);
|
||||
if (decoded) {
|
||||
console.log("Renewing JWT via websocket");
|
||||
delete decoded.exp;
|
||||
const token = jwt.issue(decoded);
|
||||
socket.send(JSON.stringify({
|
||||
@@ -29,6 +29,7 @@ function start (server, pingInterval=30000) {
|
||||
}
|
||||
}));
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn("Websocket message decoding failed", err);
|
||||
|
||||
Reference in New Issue
Block a user