In CheckIfMyAnimeListLoggedIn and MyAnimeListLogin the keyring lookups
assigned MyAnimeListAccessToken to refreshToken and
MyAnimeListRefreshToken to accessToken. Downstream code checks
len(accessToken.Data) for login state and assigns
accessToken.Data -> myAnimeListJwt.AccessToken, so the swap gated
login on the refresh token and stored each token in the wrong field.
Swap the variable names to match their keyring keys so login detection,
JWT restoration, and the empty-token fallback in MyAnimeListLogin use
the correct values.
Two MAL login issues were caused by the refresh path being conflated
with the full browser OAuth flow:
1. A spurious 'It is now safe to close your browser tab' dialog was
shown after a *silent* background token refresh, even though the
browser was never opened. The dialog now belongs only to the
browser-callback handler (handleMyAnimeListCallback); the refresh
raises no dialog.
2. When both the access token and the refresh token were invalid, the
app reported MAL as logged in without a username. Now, if a refresh
fails (HttpClient error, non-2xx, or an empty access token), the
stale tokens are cleared and a fresh browser OAuth login is
automatically initiated instead of silently returning an empty user.
refreshMyAnimeListAuthorizationToken now returns a bool indicating
whether a fresh access token was actually obtained, letting
GetMyAnimeListLoggedInUser decide between retrying with the refreshed
token or falling back to a full re-login.
MALFunctions.go:
- Update MALHelper to return (json.RawMessage, string, error)
- Add network error handling and proper request error checking
- Update GetMyAnimeList to return (MALWatchlist, error)
- Update MyAnimeListUpdate to return (MalListStatus, error)
- Update GetMyAnimeListAnime to return (MALAnime, error)
- Update DeleteMyAnimeListEntry to return (bool, error)
MALUserFunctions.go:
- Replace log.Fatalf with log.Printf in server error handling
- Prevent server shutdown on OAuth callback errors
All MAL API calls now properly propagate errors to frontend.