O auth login is ignoring the redirect url (#17939)

* link redirect param to continue param of oauth

* redirect to the link of continue param

* add github username to contributors.yml

* save the file to run lint stage

* Resolve redirect on continue-as; fix redirect query param

* Clean up names

---------

Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com>
This commit is contained in:
Paiman Rasoli
2023-04-13 01:25:01 +04:30
committed by GitHub
parent bac5a88d6f
commit 0c874a78e8
3 changed files with 20 additions and 11 deletions

View File

@@ -71,7 +71,8 @@ export default defineComponent({
async function hydrateAndLogin() {
await hydrate();
router.push(lastPage.value || `/content`);
const redirectQuery = router.currentRoute.value.query.redirect as string;
router.push(redirectQuery || lastPage.value || `/content`);
}
},
});

View File

@@ -49,15 +49,22 @@ export default defineComponent({
() => {
ssoProviders.value = providers.value
.filter((provider: AuthProvider) => AUTH_SSO_DRIVERS.includes(provider.driver))
.map((provider: AuthProvider) => ({
name: provider.name,
label: provider.label || formatTitle(provider.name),
link: `${getRootPath()}auth/login/${provider.name}?redirect=${window.location.href.replace(
location.search,
''
)}?continue`,
icon: provider.icon ?? 'account_circle',
}));
.map((provider: AuthProvider) => {
const ssoLoginLink = new URL(window.location.origin);
ssoLoginLink.pathname = `${getRootPath()}auth/login/${provider.name}`;
const redirectToLink = new URL(window.location.href);
redirectToLink.searchParams.set('continue', '');
ssoLoginLink.searchParams.set('redirect', redirectToLink.toString());
return {
name: provider.name,
label: provider.label || formatTitle(provider.name),
link: ssoLoginLink.toString(),
icon: provider.icon ?? 'account_circle',
};
});
},
{ immediate: true }
);