Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/studio/app/login/component/SocialAuth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ const SocialAuth = ({ isLoading, setIsLoading }: SocialAuthProps) => {
`/login/callback?callbackURL=${encodeURIComponent(callbackURL)}` +
(ref ? `&ref=${encodeURIComponent(ref)}` : "");
const absoluteCallbackURL = `${window.location.origin}${callbackPath}`;
const absoluteErrorCallbackURL = `${window.location.origin}/login?error=cancelled`;

await authClient.signIn.social({
provider,
callbackURL: absoluteCallbackURL,
errorCallbackURL: absoluteErrorCallbackURL,
});
} catch (err: unknown) {
const message = err instanceof Error ? err.message : "Social authentication failed.";
Expand Down
19 changes: 19 additions & 0 deletions apps/studio/app/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,25 @@ const LoginPage = () => {
}).catch(() => sessionStorage.removeItem(`affiliate-click:${code}`));
}, []);

useEffect(() => {
const searchParams = new URLSearchParams(window.location.search);
const error = searchParams.get("error");

if (error) {
if (error === "access_denied" || error === "cancelled") {
toast.info("Sign in was cancelled.");
} else {
toast.error("Sign in failed. Please try again.");
}

// Clean up the error query parameters from URL without reloading
const url = new URL(window.location.href);
url.searchParams.delete("error");
url.searchParams.delete("error_description");
window.history.replaceState({}, "", url.pathname + (url.search ? url.search : ""));
}
}, []);

const handleGuestAccess = () => {
const searchParams = new URLSearchParams(window.location.search);
const callbackURL = searchParams.get("callbackURL");
Expand Down
Loading