[PR #1836] [MERGED] Fixed issues with logging out inactive accounts #3168

Closed
opened 2025-11-26 23:29:11 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/bitwarden/android/pull/1836
Author: @mpbw2
Created: 3/10/2022
Status: Merged
Merged: 3/10/2022
Merged by: @mpbw2

Base: masterHead: bugfix-inactivelogout


📝 Commits (1)

  • 1f5e9e6 fixed issues with logging out inactive accounts

📊 Changes

3 files changed (+37 additions, -52 deletions)

View changed files

📝 src/App/Utilities/AppHelpers.cs (+16 -29)
📝 src/Core/Abstractions/IStateService.cs (+2 -2)
📝 src/Core/Services/StateService.cs (+19 -21)

📄 Description

Type of change

  • Bug fix
  • New feature development
  • Tech debt (refactoring, code cleanup, dependency upgrades, etc)
  • Build/deploy pipeline (DevOps)
  • Other

Objective

Fixed two issues with logging out inactive accounts:

  • Active account could be changed even though it wasn't the account being logged out
  • In-memory decryption keys were being removed for other accounts, resetting them to a locked state

Other things fixed along the way:

  • Fixed issue where account removal would reset "Theme" and "Show Website Icons" settings for all users
  • Removed redundant account deletion operations
  • Removed unused userId args for LastFileCacheClear getter/setter

Code changes

  • AppHelpers.cs:
    • Removed calls to xService.ClearAsync as 1) that's already handled by stateService.LogoutAccountAsync and 2) it was also clearing cache regardless of which user was being logged out (should only happen for the active user since we anticipate automatically switching to another user)
    • Established "logged out" vs "removed" toast text earlier in the logout process since automatic account switching could result in incorrect state detection
    • Moved service cache clearing to a dedicated method
  • StateService.cs:
    • Removed redundant call to CheckState when checking for active account
    • Only perform automatic account switching after account removal if the ActiveUserId is null (which only results if the account being removed is the active account)
    • Removed unused userId args for LastFileCacheClear getter/setter (this isn't a user-specific value)
    • Don't perform SetValueGloballyAsync if the value is null (to prevent global removal of Theme and Favicon settings when account is removed)
    • Don't overwrite _state from storage in GetAccountAsync if the account doesn't exist in memory (this was the main culprit behind all accounts being locked, since existing VolatileData in _state.Accounts was being wiped out (they aren't stored in storage), resetting all other accounts to a locked state. Somehow I was tricking myself into not running into this problem until now)

Testing requirements

https://app.asana.com/0/1201803072708593/1201929380000890/f

Before you submit

  • I have added unit tests where it makes sense to do so (encouraged but not required)
  • This change requires a documentation update (notify the documentation team)
  • This change has particular deployment requirements (notify the DevOps team)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/bitwarden/android/pull/1836 **Author:** [@mpbw2](https://github.com/mpbw2) **Created:** 3/10/2022 **Status:** ✅ Merged **Merged:** 3/10/2022 **Merged by:** [@mpbw2](https://github.com/mpbw2) **Base:** `master` ← **Head:** `bugfix-inactivelogout` --- ### 📝 Commits (1) - [`1f5e9e6`](https://github.com/bitwarden/android/commit/1f5e9e6925d11f62c1fd36e2ca1779e58571dd99) fixed issues with logging out inactive accounts ### 📊 Changes **3 files changed** (+37 additions, -52 deletions) <details> <summary>View changed files</summary> 📝 `src/App/Utilities/AppHelpers.cs` (+16 -29) 📝 `src/Core/Abstractions/IStateService.cs` (+2 -2) 📝 `src/Core/Services/StateService.cs` (+19 -21) </details> ### 📄 Description ## Type of change - [X] Bug fix - [ ] New feature development - [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc) - [ ] Build/deploy pipeline (DevOps) - [ ] Other ## Objective <!--Describe what the purpose of this PR is. For example: what bug you're fixing or what new feature you're adding--> Fixed two issues with logging out inactive accounts: - Active account could be changed even though it wasn't the account being logged out - In-memory decryption keys were being removed for other accounts, resetting them to a locked state Other things fixed along the way: - Fixed issue where account removal would reset "Theme" and "Show Website Icons" settings for all users - Removed redundant account deletion operations - Removed unused `userId` args for `LastFileCacheClear` getter/setter ## Code changes <!--Explain the changes you've made to each file or major component. This should help the reviewer understand your changes--> <!--Also refer to any related changes or PRs in other repositories--> * **AppHelpers.cs:** - Removed calls to `xService.ClearAsync` as 1) that's already handled by `stateService.LogoutAccountAsync` and 2) it was also clearing cache regardless of which user was being logged out (should only happen for the active user since we anticipate automatically switching to another user) - Established "logged out" vs "removed" toast text earlier in the logout process since automatic account switching could result in incorrect state detection - Moved service cache clearing to a dedicated method * **StateService.cs:** - Removed redundant call to `CheckState` when checking for active account - Only perform automatic account switching after account removal if the ActiveUserId is null (which only results if the account being removed is the active account) - Removed unused `userId` args for `LastFileCacheClear` getter/setter (this isn't a user-specific value) - Don't perform `SetValueGloballyAsync` if the value is null (to prevent global removal of Theme and Favicon settings when account is removed) - Don't overwrite `_state` from storage in `GetAccountAsync` if the account doesn't exist in memory (this was the main culprit behind all accounts being locked, since existing VolatileData in `_state.Accounts` was being wiped out (they aren't stored in storage), resetting all other accounts to a locked state. Somehow I was tricking myself into not running into this problem until now) ## Testing requirements <!--What functionality requires testing by QA? This includes testing new behavior and regression testing--> https://app.asana.com/0/1201803072708593/1201929380000890/f ## Before you submit - [ ] I have added **unit tests** where it makes sense to do so (encouraged but not required) - [ ] This change requires a **documentation update** (notify the documentation team) - [ ] This change has particular **deployment requirements** (notify the DevOps team) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-26 23:29:11 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/android#3168