Skip to content

Commit 533b216

Browse files
authored
fix: redirect back to url visited after logging in (#1733)
1 parent 4275694 commit 533b216

File tree

3 files changed

+3
-12
lines changed

3 files changed

+3
-12
lines changed

ui/admin/app/components/signin/SignIn.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export function SignIn({ className }: SignInProps) {
5454
variant="secondary"
5555
className="mb-4 w-full"
5656
onClick={() => {
57-
window.location.href = `/oauth2/start?rd=/admin/&obot-auth-provider=default/${provider.id}`;
57+
window.location.href = `/oauth2/start?rd=${window.location.pathname}&obot-auth-provider=default/${provider.id}`;
5858
}}
5959
>
6060
<ProviderIcon provider={provider} size="md" />

ui/user/src/routes/+page.svelte

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,8 @@
7676
<div class="mt-32 flex flex-col items-center gap-4">
7777
{#each authProviders as provider}
7878
<a
79-
onclick={() => {
80-
window.location.href =
81-
'/oauth2/start?rd=' +
82-
window.location.pathname +
83-
'&obot-auth-provider=' +
84-
provider.namespace +
85-
'/' +
86-
provider.id;
87-
}}
8879
rel="external"
89-
href={`/oauth2/start?obot-auth-provider=${provider.namespace}/${provider.id}&rd=/`}
80+
href={`/oauth2/start?rd=${new URL(window.location.href).searchParams.get('rd') || window.location.pathname}&obot-auth-provider=${provider.namespace}/${provider.id}`}
9081
class="group flex items-center gap-1 rounded-full bg-black p-2 px-8 text-lg font-semibold text-white dark:bg-white dark:text-black"
9182
>
9283
{#if provider.icon}

ui/user/src/routes/[agent]/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
$effect(() => {
1717
if (profile.current.unauthorized) {
1818
// Redirect to the main page to log in.
19-
window.location.href = '/';
19+
window.location.href = `/?rd=${window.location.pathname}`;
2020
}
2121
});
2222
</script>

0 commit comments

Comments
 (0)