Skip to content

Commit

Permalink
feat: remain logged in during broker outages
Browse files Browse the repository at this point in the history
Previously, we precisely tracked the broker state and logged the user
out in case the broker disappeared. This however made it impossible to
auto-disable the broker after some time and only re-enable it when
needed again.

Now, we keep the user logged in once the frontend communicated once with
the broker. When needed again, we just call into the backend and let it
handle the startup, waiting and errors.

Signed-off-by: Felix Moessbauer <[email protected]>
  • Loading branch information
fmoessbauer committed Sep 23, 2024
1 parent 1fd4727 commit 04c06aa
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async function waitFor(f) {
* Check if all conditions for SSO are met
*/
function is_operational() {
return state_active && accounts.active && broker_online
return state_active && accounts.active
}

/*
Expand Down Expand Up @@ -327,12 +327,14 @@ async function on_message_native(response) {
if (response.message == 'online') {
ssoLog('connection to broker restored');
broker_online = true;
await load_accounts();
port_native.postMessage({'command': 'getVersion'});
// only reload data if we did not see the broker before
if (host_versions.native === null) {
await load_accounts();
port_native.postMessage({'command': 'getVersion'});
}
} else {
ssoLog('lost connection to broker');
broker_online = false;
logout();
}
}
else {
Expand Down

0 comments on commit 04c06aa

Please sign in to comment.