[Fix] Websocket Tokens Refresh issue (#944)

* - Temporary fix for token refresh issue.

More testing is needed.

* Update server-console.blade.php

Removal of final old token var (no longer needed as livewire will handle it through piping)
This commit is contained in:
Alexander Featherson 2025-01-25 16:29:01 -05:00 committed by GitHub
parent 654143addc
commit 401026efa1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 11 deletions

View File

@ -103,6 +103,12 @@ class ServerConsole extends Widget
}
}
#[On('token-request')]
public function tokenRequest(): void
{
$this->dispatch('sendAuthRequest', token: $this->getToken());
}
#[On('store-stats')]
public function storeStats(string $data): void
{

View File

@ -113,7 +113,6 @@
terminal.writeln(TERMINAL_PRELUDE + 'Server marked as ' + state + '...\u001b[0m');
const socket = new WebSocket("{{ $this->getSocket() }}");
let token = '{{ $this->getToken() }}';
socket.onerror = (event) => {
$wire.dispatchSelf('websocket-error');
@ -149,21 +148,13 @@
break;
case 'token expiring':
case 'token expired':
token = '{{ $this->getToken() }}';
socket.send(JSON.stringify({
'event': 'auth',
'args': [token]
}));
$wire.dispatchSelf('token-request');
break;
}
};
socket.onopen = (event) => {
socket.send(JSON.stringify({
'event': 'auth',
'args': [token]
}));
$wire.dispatchSelf('token-request');
};
Livewire.on('setServerState', ({ state, uuid }) => {
@ -178,6 +169,13 @@
}));
});
$wire.on('sendAuthRequest', ({ token }) => {
socket.send(JSON.stringify({
'event': 'auth',
'args': [token]
}));
});
$wire.on('sendServerCommand', ({ command }) => {
socket.send(JSON.stringify({
'event': 'send command',