fix: resolve OAuth and SSO migration issues
Description
1. Resolved issue with Murena and Google account sync
For a non-SSO Murena account already set up, if users try to add a Google or Yahoo account later, Account Manager would incorrectly update the Murena account's authState with Google/Yahoo's authState.
Users would see no Google/Yahoo account added in the Account Manager and the affected Murena account would behave incorrectly too.
This bug was introduced in the SSO migration code.
The fix checks the new account's name and type with the existing non-SSO Murena accounts and only proceeds if there's a match.
2. Resolved auth state updating logic
updateAuthState() method now correctly updates the associated account and saves them inside user data.
Previously, for re-auth and SSO migration, the update method would replace all existing account's auth state with the latest one.
This is an old bug that predates SSO migration.
Tests
Required OS version: /e/OS v3.1-beta/rc onwards
Problem 1
- Remove all accounts from Account Manager; start fresh.
- Add a Murena account with username and password (use specific server if the password box is hidden initially).
- Let the sync complete; wait for a while.
- Add a Google account — complete the login steps.
- Observe that the Google account is not available in the Account Manager, even though the account addition seems successful.
In the fixed version, both the accounts will be available and will sync correctly.
Problem 2
- Remove all accounts from Account Manager; start fresh.
- Add a Murena account with username and password (use specific server if the password box is hidden initially).
- Let the sync complete; wait for a while.
- Add a Google and/or a Yahoo account.
- Let the sync complete; wait for a while.
- Reboot the device.
- Ensure the Murena SSO migration notification appears.
- Click on the notification and complete the migration.
- Observe that Google/Yahoo sync is not working. If you have HTTP Toolkit, observe that the requests are getting HTTP 401 Unauthorized response.
- Observe that Murena sync works.
- Go to the re-authentication setting for Google/Yahoo.
- Do a re-auth.
- Observe that sync works again for the re-authed account.
- If you have set up all three accounts — Murena, Google, and Yahoo — observe that after SSO migration, Google and Yahoo both will have sync errors — confirm via HTTP Toolkit.
- If you do a re-auth on any of the accounts, Murena and the account re-authed will be syncing; the remaining account will not sync.
In the fixed version, all three accounts live side-by-side without affecting others.
Issues
https://gitlab.e.foundation/e/os/backlog/-/issues/3540