diff --git a/MALUserFunctions.go b/MALUserFunctions.go index d2ddcb3..284d9b1 100644 --- a/MALUserFunctions.go +++ b/MALUserFunctions.go @@ -308,7 +308,16 @@ func refreshMyAnimeListAuthorizationToken() { func (a *App) GetMyAnimeListLoggedInUser() MyAnimeListUser { a.MyAnimeListLogin() + user := createUser() + if user.Name == "" { + refreshMyAnimeListAuthorizationToken() + user = createUser() + } + return user +} + +func createUser() MyAnimeListUser { client := &http.Client{} req, _ := http.NewRequest("GET", "https://api.myanimelist.net/v2/users/@me?fields=anime_statistics", nil) @@ -335,6 +344,7 @@ func (a *App) GetMyAnimeListLoggedInUser() MyAnimeListUser { } return user + } func (a *App) LogoutMyAnimeList() string { diff --git a/frontend/src/App.svelte b/frontend/src/App.svelte index 3a9c096..3a43a5e 100644 --- a/frontend/src/App.svelte +++ b/frontend/src/App.svelte @@ -1,7 +1,10 @@