added MAL Login
This commit is contained in:
@ -31,14 +31,13 @@ func (a *App) CheckIfAniListLoggedIn() bool {
|
||||
expiresIn, err := aniRing.Get("anilistTokenExpiresIn")
|
||||
accessToken, err := aniRing.Get("anilistAccessToken")
|
||||
refreshToken, err := aniRing.Get("anilistRefreshToken")
|
||||
if err != nil {
|
||||
if err != nil || len(accessToken.Data) == 0 {
|
||||
return false
|
||||
} else {
|
||||
aniListJwt.TokenType = string(tokenType.Data)
|
||||
aniListJwt.AccessToken = string(accessToken.Data)
|
||||
aniListJwt.RefreshToken = string(refreshToken.Data)
|
||||
expiresInString := string(expiresIn.Data)
|
||||
aniListJwt.ExpiresIn, _ = strconv.Atoi(expiresInString)
|
||||
aniListJwt.ExpiresIn, _ = strconv.Atoi(string(expiresIn.Data))
|
||||
return true
|
||||
}
|
||||
} else {
|
||||
@ -52,7 +51,7 @@ func (a *App) AniListLogin() {
|
||||
expiresIn, err := aniRing.Get("anilistTokenExpiresIn")
|
||||
accessToken, err := aniRing.Get("anilistAccessToken")
|
||||
refreshToken, err := aniRing.Get("anilistRefreshToken")
|
||||
if err != nil {
|
||||
if err != nil || len(accessToken.Data) == 0 {
|
||||
getAniListCodeUrl := "https://anilist.co/api/v2/oauth/authorize?client_id=" + os.Getenv("ANILIST_APP_ID") + "&redirect_uri=" + os.Getenv("ANILIST_CALLBACK_URI") + "&response_type=code"
|
||||
runtime.BrowserOpenURL(a.ctx, getAniListCodeUrl)
|
||||
|
||||
@ -64,8 +63,7 @@ func (a *App) AniListLogin() {
|
||||
aniListJwt.TokenType = string(tokenType.Data)
|
||||
aniListJwt.AccessToken = string(accessToken.Data)
|
||||
aniListJwt.RefreshToken = string(refreshToken.Data)
|
||||
expiresInString := string(expiresIn.Data)
|
||||
aniListJwt.ExpiresIn, _ = strconv.Atoi(expiresInString)
|
||||
aniListJwt.ExpiresIn, _ = strconv.Atoi(string(expiresIn.Data))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -89,7 +87,7 @@ func handleAniListCallback(wg *sync.WaitGroup) {
|
||||
})
|
||||
_ = aniRing.Set(keyring.Item{
|
||||
Key: "anilistTokenExpiresIn",
|
||||
Data: []byte(string(aniListJwt.ExpiresIn)),
|
||||
Data: []byte(strconv.Itoa(aniListJwt.ExpiresIn)),
|
||||
})
|
||||
_ = aniRing.Set(keyring.Item{
|
||||
Key: "anilistAccessToken",
|
||||
|
Reference in New Issue
Block a user