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,19 +16,20 @@ 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});
|
||||
// console.log("Decoded", decoded);
|
||||
if (decoded) {
|
||||
delete decoded.exp;
|
||||
const token = jwt.issue(decoded);
|
||||
socket.send(JSON.stringify({
|
||||
channel: ".jwt",
|
||||
payload: {
|
||||
token
|
||||
}
|
||||
}));
|
||||
}
|
||||
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({
|
||||
channel: ".jwt",
|
||||
payload: {
|
||||
token
|
||||
}
|
||||
}));
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn("Websocket message decoding failed", err);
|
||||
|
||||
Reference in New Issue
Block a user