Skip to content

Commit

Permalink
VPN-2934 - Fix device limit issues when logging out manually from oth…
Browse files Browse the repository at this point in the history
…er device (#4623)

* Start periodic operations timer whenver a token is available

1. That is all we need to run those operations
2. That ensures the operations are run also when in the device limit
   screen.

* Skip device check when in StateDeviceLimit

* Always enqueue a remove device task regardless if device is in
DeviceModel

TaskRemoveDevice already deals with the possibility of the device
not being registered to the given user. No need to handle
that in multiple places.

Also by not launching task remove device, operations to take
user out of device limit state don't happen and that leaves users
trapped in device limit screen.
  • Loading branch information
brizental authored Oct 18, 2022
1 parent c75f60f commit 37de80e
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/mozillavpn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,13 +352,18 @@ void MozillaVPN::setState(State state) {
emit MozillaVPN::instance()->recordGleanEventWithExtraKeys(
GleanSample::appStep, {{"state", QVariant::fromValue(state).toString()}});

// If we are activating the app, let's initialize the controller.
if (m_state == StateMain) {
m_private->m_controller.initialize();
// If we have a token, we can start periodic operations.
// If the timer is already started, this is a no-op.
if (SettingsHolder::instance()->hasToken()) {
startSchedulingPeriodicOperations();
} else {
stopSchedulingPeriodicOperations();
}

// If we are activating the app, let's initialize the controller.
if (m_state == StateMain) {
m_private->m_controller.initialize();
}
}

void MozillaVPN::maybeStateMain() {
Expand Down Expand Up @@ -682,12 +687,6 @@ void MozillaVPN::deviceRemovalCompleted(const QString& publicKey) {
void MozillaVPN::removeDeviceFromPublicKey(const QString& publicKey) {
logger.debug() << "Remove device";

const Device* device =
m_private->m_deviceModel.deviceFromPublicKey(publicKey);
if (!device) {
return;
}

// Let's emit a signal to inform the user about the starting of the device
// removal. The front-end code will show a loading icon or something
// similar.
Expand Down Expand Up @@ -810,6 +809,11 @@ bool MozillaVPN::checkCurrentDevice() {
SettingsHolder* settingsHolder = SettingsHolder::instance();
Q_ASSERT(settingsHolder);

// We are not able to check the device at this stage.
if (m_state == StateDeviceLimit) {
return false;
}

if (m_private->m_deviceModel.hasCurrentDevice(keys())) {
return true;
}
Expand Down

0 comments on commit 37de80e

Please sign in to comment.