fix(auth): return to origin path after GitHub login
Sign-in saves the current path in sessionStorage so the OAuth callback can route back instead of always landing on Home.
This commit is contained in:
@@ -3,6 +3,7 @@ import { onBeforeMount, ref } from "vue"
|
||||
import { useRoute, useRouter } from "vue-router"
|
||||
|
||||
import { useGitHubLogin } from "@/hooks/useGitHubLogin.hook"
|
||||
import { consumeGithubOAuthReturnPath } from "@/modules/user/service/oauthReturnPath"
|
||||
import { signIn } from "@/modules/user/service/signIn"
|
||||
|
||||
const route = useRoute()
|
||||
@@ -22,7 +23,13 @@ onBeforeMount(async () => {
|
||||
await saveCredentials(token)
|
||||
}
|
||||
|
||||
router.replace({ name: "Home" })
|
||||
const returnPath = consumeGithubOAuthReturnPath()
|
||||
|
||||
if (!hasError.value && returnPath) {
|
||||
router.replace(returnPath)
|
||||
} else {
|
||||
router.replace({ name: "Home" })
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user