Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VPN-5932: Change where we save a new device model #8972

Closed
wants to merge 2 commits into from

Conversation

mcleinman
Copy link
Collaborator

Description

This bug existed for the following situation:

  • Have an account with five devices.
  • Sign in on a new device
  • Remove a device from the account as part of the sign in flow
  • End up on main screen
  • Force kill app
  • Reopen it
  • Note that you need to sign in again - not what we expected

The list of valid devices comes from the Guardian, and is saved in local settings (as the device list JSON). Upon launch, we check if the current device is in those devices, and if not, we ask the user to sign in again.

When we sign into the app when an account already has max devices, we retrieve the device list from Guardian twice - once upon initial launch, and a second time after we remove a device and add our current one. However, we were only saving it to settings after that first retrieval. Thus, on subsequent launch, the current device wasn't in the saved list, signing the user out.

I updated where we save the device JSON to local settings - It's now in the function where we process the new device list from Guardian. This fixes the bug, and hopefully prevents future iterations of this bug.

Note that we save the user data in the same spot, but I am not updating it as part of this bug. Arguably, we should save it to disk in the function where we process the server response, as we're changing devices here. However, there are no known issues with it currently and I'm trying to keep this patch as small as possible.

Reference

VPN-5932

Checklist

  • My code follows the style guidelines for this project
  • I have not added any packages that contain high risk or unknown licenses (GPL, LGPL, MPL, etc. consult with DevOps if in question)
  • I have performed a self review of my own code
  • I have commented my code PARTICULARLY in hard to understand areas
  • I have added thorough tests where needed

@mcleinman mcleinman force-pushed the vpn-5932-signout-on-launch branch from db4c2a5 to ef1e27a Compare January 18, 2024 00:03
@@ -51,6 +51,9 @@ bool DeviceModel::fromJson(const Keys* keys, const QByteArray& s) {
}

m_rawJson = s;
#if !defined(UNIT_TEST)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this directive needed?

@@ -51,6 +51,9 @@ bool DeviceModel::fromJson(const Keys* keys, const QByteArray& s) {
}

m_rawJson = s;
#if !defined(UNIT_TEST)
writeSettings();
Copy link
Contributor

@vinocher vinocher Jan 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this is now a side effect of reading the device model from the Json, the previous code that used writeSettings() in the caller appears to be a better design.

AFAIK, DeviceModel::fromJson is called from MozillaVPN::completeAuthentication (with the list of devices without the current device) and MozillaVPN::accountChecked (with the list of devices including the current device), and both of them called m_deviceModel.writeSettings. So, I don't understand the cause of the bug. Could you please clarify if I'm missing something?

@mcleinman
Copy link
Collaborator Author

Closing this in favor of #9011. Thanks to @vinocher's comments, I believe I found a better solution.

@mcleinman mcleinman closed this Jan 23, 2024
@mcleinman mcleinman deleted the vpn-5932-signout-on-launch branch November 21, 2024 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants