Improved CSRF handling

This commit is contained in:
rainbow napkin 2025-05-04 17:52:55 -04:00
parent 2d5afc23d7
commit 1f00bacb6f
4 changed files with 74 additions and 8 deletions

View file

@ -48,8 +48,16 @@ class channel{
document.title = `${this.channelName} - Connected`
});
this.socket.on("kick", (data) => {
new canopyUXUtils.popup(`You have been ${data.type} from the channel for the following reason:<br>${data.reason}`);
this.socket.on("kick", async (data) => {
if(data.reason == "Invalid CSRF Token!"){
//Reload the CSRF token
await utils.ajax.reloadCSRFToken();
//Retry the connection
this.connect();
}else{
new canopyUXUtils.popup(`You have been ${data.type} from the channel for the following reason:<br>${data.reason}`);
}
});
this.socket.on("clientMetadata", this.handleClientInfo.bind(this));