fix(mal): correct swapped access and refresh token variables
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.
This commit is contained in:
+4
-4
@@ -74,8 +74,8 @@ func (a *App) CheckIfMyAnimeListLoggedIn() bool {
|
|||||||
if (MyAnimeListJWT{} == myAnimeListJwt) {
|
if (MyAnimeListJWT{} == myAnimeListJwt) {
|
||||||
tokenType, tokenErr := myAnimeListRing.Get("MyAnimeListTokenType")
|
tokenType, tokenErr := myAnimeListRing.Get("MyAnimeListTokenType")
|
||||||
expiresIn, expiresInErr := myAnimeListRing.Get("MyAnimeListExpiresIn")
|
expiresIn, expiresInErr := myAnimeListRing.Get("MyAnimeListExpiresIn")
|
||||||
refreshToken, refreshTokenErr := myAnimeListRing.Get("MyAnimeListAccessToken")
|
accessToken, accessTokenErr := myAnimeListRing.Get("MyAnimeListAccessToken")
|
||||||
accessToken, accessTokenErr := myAnimeListRing.Get("MyAnimeListRefreshToken")
|
refreshToken, refreshTokenErr := myAnimeListRing.Get("MyAnimeListRefreshToken")
|
||||||
if (tokenErr != nil || expiresInErr != nil || refreshTokenErr != nil || accessTokenErr != nil) || len(accessToken.Data) == 0 {
|
if (tokenErr != nil || expiresInErr != nil || refreshTokenErr != nil || accessTokenErr != nil) || len(accessToken.Data) == 0 {
|
||||||
return false
|
return false
|
||||||
} else {
|
} else {
|
||||||
@@ -99,8 +99,8 @@ func (a *App) MyAnimeListLogin() {
|
|||||||
fmt.Println("check logged in function failed")
|
fmt.Println("check logged in function failed")
|
||||||
tokenType, tokenErr := myAnimeListRing.Get("MyAnimeListTokenType")
|
tokenType, tokenErr := myAnimeListRing.Get("MyAnimeListTokenType")
|
||||||
expiresIn, expiresInErr := myAnimeListRing.Get("MyAnimeListExpiresIn")
|
expiresIn, expiresInErr := myAnimeListRing.Get("MyAnimeListExpiresIn")
|
||||||
refreshToken, refreshTokenErr := myAnimeListRing.Get("MyAnimeListAccessToken")
|
accessToken, accessTokenErr := myAnimeListRing.Get("MyAnimeListAccessToken")
|
||||||
accessToken, accessTokenErr := myAnimeListRing.Get("MyAnimeListRefreshToken")
|
refreshToken, refreshTokenErr := myAnimeListRing.Get("MyAnimeListRefreshToken")
|
||||||
if (tokenErr != nil || expiresInErr != nil || refreshTokenErr != nil || accessTokenErr != nil) || len(accessToken.Data) == 0 {
|
if (tokenErr != nil || expiresInErr != nil || refreshTokenErr != nil || accessTokenErr != nil) || len(accessToken.Data) == 0 {
|
||||||
verifier, _ := verifier()
|
verifier, _ := verifier()
|
||||||
getMyAnimeListCodeUrl := "https://myanimelist.net/v1/oauth2/authorize?response_type=code&client_id=" + Environment.MAL_CLIENT_ID + "&redirect_uri=" + Environment.MAL_CALLBACK_URI + "&code_challenge=" + verifier.Value + "&code_challenge_method=plain"
|
getMyAnimeListCodeUrl := "https://myanimelist.net/v1/oauth2/authorize?response_type=code&client_id=" + Environment.MAL_CLIENT_ID + "&redirect_uri=" + Environment.MAL_CALLBACK_URI + "&code_challenge=" + verifier.Value + "&code_challenge_method=plain"
|
||||||
|
|||||||
Reference in New Issue
Block a user