-
Notifications
You must be signed in to change notification settings - Fork 119
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 device model #9011
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my understanding, could you please explain the call sequence? When the user signs in, I think MozillaVPN::completeAuthentication calls DeviceModel::fromJson to add the user's other devices. Then MozillaVPN::accountChecked calls DeviceModel::fromJson with all devices, including the current device.
AFAIK, MozillaVPN::maybeStateMain sets the StateDeviceLimit state, which is checked by checkCurrentDevice. But MozillaVPN::maybeStateMain seems to be called after MozillaVPN::accountChecked. If so, I'm not sure how this change fixes the issue. I'm likely misunderstanding something, so would appreciate some clarification.
While When a user already has 5 devices when signing in, they're prompted to remove a device. After the user selects which device to remove, Please let me know if any of this didn't make sense - happy to explain more/better. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanation!
@@ -746,13 +746,13 @@ void MozillaVPN::accountChecked(const QByteArray& json) { | |||
return; | |||
} | |||
|
|||
m_private->m_user.writeSettings(); | |||
m_private->m_deviceModel.writeSettings(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A comment here may be useful to explain why the device model is being written before checkCurrentDevice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, thanks. Just added some comments, with a link to the full explanation here.
Description
This bug existed for the following situation:
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 before we check the current device.
checkCurrentDevice
returns false here, because the state isStateDeviceLimit
- but we want to save the new devices anyway.Note that we save the user data in the same spot, and I moved it as well.
Reference
VPN-5932
Checklist