Files
iNaturalistReactNative/tests/unit/components
Johannes Klein 164ca02fa0 Replace involuntary sign out on jwt 401 with user action to login again (#3502)
* MOB-1276: first pass

* Move realm clearing below other resets

Before we were seeing a crash where a user signsOut and while deleting realm still has a reference to a realm object somewhere the app crashes (something along the lines of "accessing object which has been invalidated or deleted", I think). Which meant that subsequent lines here after reaml.deleteAll were never hit. So, we got rid of realm but still had the signals that the user is logged in like jwt and mmkv stuff. This is problematic because UI and server request have different definitions of a user is logged in: 1) sensitive item named "username" exists, and 2) realm entry for current user exists.
I don't see how this change here get's rid of the actual crash, but at least we maybe have more likelihood of deleting all things we want to delete here.

According to @FLGMwt s investigations into this this closes MOB-820 https://linear.app/inaturalist/issue/MOB-820/user-account-seem-to-be-mixed-up#comment-80cd5378

* Do not clear auth cache and sensitive info on automatic login again initiation

I think we should fully rely on the login again action to refresh jwtToken, jwtGeneratedAt, and accessToken.

We don't know which one of them is corrupt at this point, and a re-login will give us correct new ones.

* Remove comments

A) I don't think it means that *for any reason* we delete the local database. Only when we had a 401 we were deleting everything.
B) is alleviated

* Quick fix idea

If we are on the login screen for the login again flow do not show a close button. This means the user has to close the app and open again. If the 401 persists the only action the user can take is to do the login again.

* Alternative fix: sign out on login again flow close

Adding back the X button to the login flow. Pressing it explains that this is a sign out action and signs the user out making sure we also clear realm during an entire sign out deletion flow.

* Remove test

* Update src/components/LoginSignUp/LoginForm.tsx

Co-authored-by: Ryan Stelly <ryan@inaturalist.org>

* Clean up previous code suggestion

* Revert "Clean up previous code suggestion"

This reverts commit 345bb31510.

* Revert "Update src/components/LoginSignUp/LoginForm.tsx"

This reverts commit 968fcd8601.

---------

Co-authored-by: sepeterson <10458078+sepeterson@users.noreply.github.com>
Co-authored-by: Ryan Stelly <ryan@inaturalist.org>
2026-04-08 22:34:35 +02:00
..
2026-01-15 13:32:06 -08:00
2026-01-15 13:32:06 -08:00
2026-03-31 15:41:20 -07:00
2026-01-20 11:32:59 -06:00
2026-03-30 11:55:44 -07:00