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:
Julien Calixte
2026-05-29 16:49:44 +02:00
parent a09e541fa8
commit d99672dbd8
3 changed files with 30 additions and 2 deletions

View File

@@ -1,20 +1,34 @@
<script lang="ts" setup>
import { useRoute } from "vue-router"
import { GITHUB_OAUTH_RETURN_PATH_KEY } from "@/modules/user/service/oauthReturnPath"
const GITHUB_URL = "https://github.com/login/oauth/authorize"
const CLIENT_ID = "Iv1.12dc43d013ce3623"
const SCOPE = "repo%20workflow"
const REDIRECT_URI = window.location.origin
const route = useRoute()
const url = new URL(GITHUB_URL)
url.searchParams.set("client_id", CLIENT_ID)
url.searchParams.set("scope", SCOPE)
url.searchParams.set("redirect_uri", REDIRECT_URI)
const href = url.toString()
const saveReturnPath = () => {
sessionStorage.setItem(GITHUB_OAUTH_RETURN_PATH_KEY, route.fullPath)
}
</script>
<template>
<a :href="href" class="sign-in-github btn btn-sm btn-primary">
<a
:href="href"
class="sign-in-github btn btn-sm btn-primary"
@click="saveReturnPath"
>
Sign in with
<svg
xmlns="http://www.w3.org/2000/svg"