♻️ Refactored the auth flow

This commit is contained in:
2025-10-01 22:52:23 +08:00
parent 3e68158b4e
commit 6853acea98
4 changed files with 23 additions and 63 deletions

View File

@@ -201,7 +201,8 @@ async function exchangeToken() {
isLoading.value = true
error.value = null
try {
const tokenResponse = await api<{ token: string }>("/id/auth/token", {
// The token endpoint gives the Set-Cookie header
await api<{ token: string }>("/id/auth/token", {
method: "POST",
body: {
grant_type: "authorization_code",
@@ -209,11 +210,6 @@ async function exchangeToken() {
}
})
// Store the token in localStorage via user store
if (tokenResponse && tokenResponse.token) {
userStore.setToken(tokenResponse.token)
}
await userStore.fetchUser()
const redirectUri = route.query.redirect_uri as string
@@ -374,14 +370,14 @@ const colorMode = useColorMode()
factor.type === 0
? "mdi-lock"
: factor.type === 1
? "mdi-email"
: factor.type === 2
? "mdi-cellphone"
: factor.type === 3
? "mdi-clock"
: factor.type === 4
? "mdi-numeric"
: "mdi-shield-key"
? "mdi-email"
: factor.type === 2
? "mdi-cellphone"
: factor.type === 3
? "mdi-clock"
: factor.type === 4
? "mdi-numeric"
: "mdi-shield-key"
}}</v-icon>
</template>
</v-list-item>