This commit modifies the connect flow in `ConnectViewModel.kt` to clear the profile-specific token alongside the global token when an HTTP 401 (Unauthorized) error is encountered. Previously, the global token was cleared, but the bad token persisted in the selected profile's slot, causing potential security and authentication handling issues. Tests have been added to `ConnectViewModelTest.kt` to verify that both the global and profile tokens are correctly nullified under a 401 scenario.
This commit is contained in:
2 files changed
+32
No files matched your search
@@ -188,6 +188,9 @@ class ConnectViewModel(private val app: Application) : ViewModel() {
|
||||
when (err.code) {
|
||||
401 -> {
|
||||
AuthManager.setToken(null)
|
||||
if (AuthManager.getSelectedProfileId() != null) {
|
||||
AuthManager.setProfileToken(AuthManager.getSelectedProfileId()!!, null)
|
||||
}
|
||||
app.getString(R.string.connect_error_401)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user