A previous commit that sent unauthorized if the user is unauthorized
simply leads to the repeated reopening of the eventsource. #
This PR changes the event returned to tell the client to close the
eventsource and thus prevents the repeated reopening.
Signed-off-by: Andrew Thornton <art27@cantab.net>
if !ctx.IsSigned {
// Return unauthorized status event
event := (&eventsource.Event{
- Name: "unauthorized",
- Data: "sorry",
+ Name: "close",
+ Data: "unauthorized",
})
_, _ = event.WriteTo(ctx)
ctx.Resp.Flush()
this.listening = {};
this.clients = [];
this.listen('open');
+ this.listen('close');
this.listen('logout');
this.listen('notification-count');
this.listen('stopwatches');
});
worker.port.close();
window.location.href = AppSubUrl;
+ } else if (event.data.type === 'close') {
+ worker.port.postMessage({
+ type: 'close',
+ });
+ worker.port.close();
}
});
worker.port.addEventListener('error', (e) => {
});
worker.port.close();
window.location.href = AppSubUrl;
+ } else if (event.data.type === 'close') {
+ worker.port.postMessage({
+ type: 'close',
+ });
+ worker.port.close();
}
});
worker.port.addEventListener('error', (e) => {