fix: oauth 2.0 authentication type is breaking (#3531)

This commit is contained in:
Akash K
2023-11-14 00:12:04 +05:30
committed by GitHub
parent de725337d6
commit e24d0ce605
6 changed files with 187 additions and 95 deletions

View File

@@ -0,0 +1,43 @@
<template>
<div class="flex justify-center items-center">
<HoppSmartSpinner />
</div>
</template>
<script setup lang="ts">
import { handleOAuthRedirect } from "~/helpers/oauth"
import { useToast } from "~/composables/toast"
import * as E from "fp-ts/Either"
import { useService } from "dioc/vue"
import { RESTTabService } from "~/services/tab/rest"
import { onMounted } from "vue"
import { useRouter } from "vue-router"
const router = useRouter()
const toast = useToast()
const tabs = useService(RESTTabService)
onMounted(async () => {
const tokenInfo = await handleOAuthRedirect()
if (E.isLeft(tokenInfo)) {
toast.error(tokenInfo.left)
router.push("/")
return
}
if (
tabs.currentActiveTab.value.document.request.auth.authType === "oauth-2"
) {
tabs.currentActiveTab.value.document.request.auth.token =
tokenInfo.right.access_token
router.push("/")
return
}
})
</script>