[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')]
|
#[On('store-stats')]
|
||||||
public function storeStats(string $data): void
|
public function storeStats(string $data): void
|
||||||
{
|
{
|
||||||
|
@ -113,7 +113,6 @@
|
|||||||
terminal.writeln(TERMINAL_PRELUDE + 'Server marked as ' + state + '...\u001b[0m');
|
terminal.writeln(TERMINAL_PRELUDE + 'Server marked as ' + state + '...\u001b[0m');
|
||||||
|
|
||||||
const socket = new WebSocket("{{ $this->getSocket() }}");
|
const socket = new WebSocket("{{ $this->getSocket() }}");
|
||||||
let token = '{{ $this->getToken() }}';
|
|
||||||
|
|
||||||
socket.onerror = (event) => {
|
socket.onerror = (event) => {
|
||||||
$wire.dispatchSelf('websocket-error');
|
$wire.dispatchSelf('websocket-error');
|
||||||
@ -149,21 +148,13 @@
|
|||||||
break;
|
break;
|
||||||
case 'token expiring':
|
case 'token expiring':
|
||||||
case 'token expired':
|
case 'token expired':
|
||||||
token = '{{ $this->getToken() }}';
|
$wire.dispatchSelf('token-request');
|
||||||
|
|
||||||
socket.send(JSON.stringify({
|
|
||||||
'event': 'auth',
|
|
||||||
'args': [token]
|
|
||||||
}));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
socket.onopen = (event) => {
|
socket.onopen = (event) => {
|
||||||
socket.send(JSON.stringify({
|
$wire.dispatchSelf('token-request');
|
||||||
'event': 'auth',
|
|
||||||
'args': [token]
|
|
||||||
}));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Livewire.on('setServerState', ({ state, uuid }) => {
|
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 }) => {
|
$wire.on('sendServerCommand', ({ command }) => {
|
||||||
socket.send(JSON.stringify({
|
socket.send(JSON.stringify({
|
||||||
'event': 'send command',
|
'event': 'send command',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user