[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:
parent
654143addc
commit
401026efa1
@ -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
|
||||
{
|
||||
|
@ -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',
|
||||
|
Loading…
x
Reference in New Issue
Block a user