Skip to content

Commit

Permalink
VPN-6570/VPN-6583: Fix logout race condition when VPN is active (#9859)
Browse files Browse the repository at this point in the history
* Fix logout race condition when VPN is active
* Fix build fail in unit tests
  • Loading branch information
oskirby authored Sep 11, 2024
1 parent fad1e36 commit 1611944
Show file tree
Hide file tree
Showing 10 changed files with 7 additions and 27 deletions.
2 changes: 1 addition & 1 deletion nebula/ui/components/MZSignOut.qml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ MZFooterLink {

onClicked: () => {
preLogoutCallback();
VPNController.logout();
VPN.logout();
}
}
17 changes: 0 additions & 17 deletions src/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,23 +372,6 @@ void Controller::updateRequired() {
}
}

void Controller::logout() {
logger.debug() << "Logout";

MozillaVPN::instance()->logout();

if (m_state == StateOff) {
return;
}

m_nextStep = Disconnect;

if (m_state == StateOn || m_state == StateOnPartial) {
deactivate();
return;
}
}

void Controller::activateInternal(
DNSPortPolicy dnsPort,
ServerSelectionPolicy serverSelectionPolicy = RandomizeServerSelection,
Expand Down
1 change: 0 additions & 1 deletion src/controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ class Controller : public QObject, public LogSerializer {

int connectionRetry() const { return m_connectionRetry; }
State state() const;
Q_INVOKABLE void logout();
bool silentServerSwitchingSupported() const;
void cleanupBackendLogs();

Expand Down
2 changes: 2 additions & 0 deletions src/mozillavpn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,8 @@ void MozillaVPN::logout() {

ErrorHandler::instance()->requestAlert(ErrorHandler::LogoutAlert);

deactivate();

TaskScheduler::deleteTasks();

// Schedule the removal of our device and let it run in the background.
Expand Down
2 changes: 1 addition & 1 deletion src/mozillavpn.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class MozillaVPN final : public App {

Q_INVOKABLE void silentSwitch();

void logout();
Q_INVOKABLE void logout();

bool startMinimized() const { return m_startMinimized; }

Expand Down
2 changes: 1 addition & 1 deletion src/ui/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ Window {
Connections {
target: VPN
function onAccountDeleted() {
VPNController.logout();
VPN.logout();
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/ui/screens/ScreenSubscriptionInUseError.qml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ MZStackView {
primaryButtonText: MZI18n.GlobalSignOut,
primaryButtonObjectName: "errorSignOutButton",
primaryButtonOnClick: () => {
VPNController.logout();
VPN.logout();
stackView.pop();
},
secondaryButtonIsSignOff: false,
Expand Down
2 changes: 1 addition & 1 deletion src/ui/screens/devices/ViewDeviceLimit.qml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ MZViewBase {
labelText: MZI18n.GlobalSignOut
fontName: MZTheme.theme.fontBoldFamily
linkColor: MZTheme.theme.redLinkButton
onClicked: VPNController.logout();
onClicked: VPN.logout();
}
}

Expand Down
2 changes: 0 additions & 2 deletions tests/qml/moccontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ void Controller::disconnected() {}

void Controller::timerTimeout() {}

void Controller::logout() {}

bool Controller::processNextStep() { return false; }

void Controller::setState(State) {}
Expand Down
2 changes: 0 additions & 2 deletions tests/unit/moccontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ void Controller::disconnected() {}

void Controller::timerTimeout() {}

void Controller::logout() {}

bool Controller::processNextStep() { return false; }

void Controller::setState(State) {}
Expand Down

0 comments on commit 1611944

Please sign in to comment.