added logout functions
This commit is contained in:
parent
0ae1e4cb7d
commit
90b68b717a
@ -200,3 +200,18 @@ func (a *App) GetAniListLoggedInUser() AniListUser {
|
||||
|
||||
return post
|
||||
}
|
||||
|
||||
func (a *App) LogoutAniList() string {
|
||||
if (AniListJWT{} != aniListJwt) {
|
||||
err := aniRing.Remove("anilistTokenType")
|
||||
err = aniRing.Remove("anilistTokenExpiresIn")
|
||||
err = aniRing.Remove("anilistAccessToken")
|
||||
err = aniRing.Remove("anilistRefreshToken")
|
||||
|
||||
if err != nil {
|
||||
fmt.Println("AniList Logout Failed", err)
|
||||
}
|
||||
}
|
||||
|
||||
return "AniList Logged Out Successfully"
|
||||
}
|
||||
|
@ -256,3 +256,18 @@ func (a *App) GetMyAnimeListLoggedInUser() MyAnimeListUser {
|
||||
|
||||
return user
|
||||
}
|
||||
|
||||
func (a *App) LogoutMyAnimeList() string {
|
||||
if (MyAnimeListJWT{} != myAnimeListJwt) {
|
||||
err := myAnimeListRing.Remove("MyAnimeListTokenType")
|
||||
err = myAnimeListRing.Remove("MyAnimeListExpiresIn")
|
||||
err = myAnimeListRing.Remove("MyAnimeListAccessToken")
|
||||
err = myAnimeListRing.Remove("MyAnimeListRefreshToken")
|
||||
|
||||
if err != nil {
|
||||
fmt.Println("MAL Logout Failed", err)
|
||||
}
|
||||
}
|
||||
|
||||
return "MAL Logged Out Successfully"
|
||||
}
|
||||
|
@ -193,3 +193,17 @@ func (a *App) GetSimklLoggedInUser() SimklUser {
|
||||
|
||||
return user
|
||||
}
|
||||
|
||||
func (a *App) LogoutSimkl() string {
|
||||
if (SimklJWT{} != simklJwt) {
|
||||
err := simklRing.Remove("SimklTokenType")
|
||||
err = simklRing.Remove("SimklAccessToken")
|
||||
err = simklRing.Remove("SimklScope")
|
||||
|
||||
if err != nil {
|
||||
fmt.Println("Simkl Logout Failed", err)
|
||||
}
|
||||
}
|
||||
|
||||
return "Simkl Logged Out Successfully"
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
import {Avatar} from "flowbite-svelte";
|
||||
import type {AniListUser} from "./anilist/types/AniListTypes";
|
||||
import {aniListLoggedIn, aniListUser, malLoggedIn, simklLoggedIn,} from "./GlobalVariablesAndHelperFunctions.svelte"
|
||||
import {aniListLoggedIn, aniListUser, malLoggedIn, simklLoggedIn, logoutOfAniList, logoutOfMAL, logoutOfSimkl} from "./GlobalVariablesAndHelperFunctions.svelte"
|
||||
import * as runtime from "../wailsjs/runtime";
|
||||
|
||||
let currentAniListUser: AniListUser
|
||||
@ -43,7 +43,7 @@
|
||||
aria-labelledby="dropdownUserAvatarButton">
|
||||
{#if isAniListLoggedIn}
|
||||
<li>
|
||||
<button
|
||||
<button on:click={logoutOfAniList}
|
||||
class="block px-4 py-2 w-full hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">
|
||||
Logout Anilist
|
||||
</button>
|
||||
@ -51,7 +51,7 @@
|
||||
{/if}
|
||||
{#if isMALLoggedIn}
|
||||
<li>
|
||||
<button
|
||||
<button on:click={logoutOfMAL}
|
||||
class="block px-4 py-2 w-full hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">
|
||||
Logout MAL
|
||||
</button>
|
||||
@ -59,7 +59,7 @@
|
||||
{/if}
|
||||
{#if isSimklLoggedIn}
|
||||
<li>
|
||||
<button
|
||||
<button on:click={logoutOfSimkl}
|
||||
class="block px-4 py-2 w-full hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">
|
||||
Logout Simkl
|
||||
</button>
|
||||
|
@ -2,7 +2,7 @@
|
||||
import {
|
||||
GetAniListItem,
|
||||
GetAniListLoggedInUser, GetAniListUserWatchingList, GetMyAnimeListLoggedInUser,
|
||||
GetSimklLoggedInUser
|
||||
GetSimklLoggedInUser, LogoutAniList, LogoutMyAnimeList, LogoutSimkl
|
||||
} from "../wailsjs/go/main/App";
|
||||
import type {
|
||||
AniListCurrentUserWatchList,
|
||||
@ -32,9 +32,12 @@
|
||||
let isAniListPrimary: boolean
|
||||
let page: number
|
||||
let perPage: number
|
||||
let aniWatchlist: AniListCurrentUserWatchList
|
||||
|
||||
aniListPrimary.subscribe(value => isAniListPrimary = value)
|
||||
watchListPage.subscribe(value => page = value)
|
||||
animePerPage.subscribe(value => perPage = value)
|
||||
aniListWatchlist.subscribe(value => aniWatchlist = value)
|
||||
|
||||
export function GetAniListSingleItemAndOpenModal(aniId: number, login: boolean): void {
|
||||
GetAniListItem(aniId, login).then(result => {
|
||||
@ -73,4 +76,31 @@
|
||||
malLoggedIn.set(true)
|
||||
})
|
||||
}
|
||||
|
||||
export function logoutOfAniList(): void {
|
||||
LogoutAniList().then(result => {
|
||||
console.log(result)
|
||||
if (Object.keys(aniWatchlist).length !== 0) {
|
||||
aniListWatchlist.set({} as AniListCurrentUserWatchList)
|
||||
}
|
||||
aniListUser.set({} as AniListUser)
|
||||
aniListLoggedIn.set(false)
|
||||
})
|
||||
}
|
||||
|
||||
export function logoutOfMAL(): void {
|
||||
LogoutMyAnimeList().then(result => {
|
||||
console.log(result)
|
||||
malUser.set({} as MyAnimeListUser)
|
||||
malLoggedIn.set(false)
|
||||
})
|
||||
}
|
||||
|
||||
export function logoutOfSimkl(): void {
|
||||
LogoutSimkl().then(result => {
|
||||
console.log(result)
|
||||
simklUser.set({} as SimklUser)
|
||||
simklLoggedIn.set(false)
|
||||
})
|
||||
}
|
||||
</script>
|
Loading…
Reference in New Issue
Block a user