-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
75 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import type Member from "@/models/member" | ||
import router from "@/router" | ||
import { createTokenViaLogtoToken } from "@/services/logto" | ||
import { useAccountStore } from "@/stores/account" | ||
|
||
export const handleCreateToken = async (token: string) => { | ||
const store = useAccountStore() | ||
const res = await createTokenViaLogtoToken(token) | ||
const body: unknown = await res.json() | ||
if (res.status == 422 && body instanceof Object && "message" in body && body.message.includes("not found")) { | ||
throw new Error("need bind member") | ||
} | ||
if (body instanceof Object && "token" in body && "memberId" in body && "role" in body) { | ||
store.account = body as Member | ||
store.token = body.token as string | ||
if (body.role instanceof Array && body.role.includes("inactive")) { | ||
router.push("/activate") | ||
router.push("/activate") | ||
} else { | ||
router.push("/Events") | ||
} | ||
} else { | ||
// setTimeout(() => { | ||
// signOut(import.meta.env.VITE_LOGTO_REDIRECT_URL) | ||
// }, 2000) | ||
} | ||
} |