Skip to content

Commit

Permalink
Rename callbackUrl to redirectTo
Browse files Browse the repository at this point in the history
  • Loading branch information
lukevella committed Feb 6, 2025
1 parent 519ada2 commit 7b0acd9
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ export function LoginWithEmailForm() {
if (doesExist) {
await signIn("email", {
email: identifier,
redirectTo: searchParams?.get("callbackUrl") ?? undefined,
redirectTo: searchParams?.get("redirectTo") ?? undefined,
redirect: false,
});
// redirect to verify page with callbackUrl
// redirect to verify page with redirectTo
router.push(
`/login/verify?callbackUrl=${encodeURIComponent(
searchParams?.get("callbackUrl") ?? "",
`/login/verify?redirectTo=${encodeURIComponent(
searchParams?.get("redirectTo") ?? "",
)}`,
);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import { Trans } from "@/components/trans";

export async function LoginWithOIDC({
name,
callbackUrl,
redirectTo,
}: {
name: string;
callbackUrl?: string;
redirectTo?: string;
}) {
return (
<Button
onClick={() => {
signIn("oidc", {
redirectTo: callbackUrl,
redirectTo: redirectTo,
});
}}
variant="link"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ function SSOImage({ provider }: { provider: string }) {
export function SSOProvider({
providerId,
name,
callbackUrl,
redirectTo,
}: {
providerId: string;
name: string;
callbackUrl?: string;
redirectTo?: string;
}) {
const { t } = useTranslation();
return (
Expand All @@ -58,7 +58,7 @@ export function SSOProvider({
key={providerId}
onClick={() => {
signIn(providerId, {
redirectTo: callbackUrl,
redirectTo: redirectTo,
});
}}
>
Expand Down
6 changes: 3 additions & 3 deletions apps/web/src/app/[locale]/(auth)/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default async function LoginPage({
searchParams,
}: {
searchParams?: {
callbackUrl?: string;
redirectTo?: string;
};
}) {
const { t } = await getTranslation();
Expand Down Expand Up @@ -54,7 +54,7 @@ export default async function LoginPage({
{oidcProvider ? (
<LoginWithOIDC
name={oidcProvider.name}
callbackUrl={searchParams?.callbackUrl}
redirectTo={searchParams?.redirectTo}
/>
) : null}
{socialProviders ? (
Expand All @@ -65,7 +65,7 @@ export default async function LoginPage({
key={provider.id}
providerId={provider.id}
name={provider.options?.name || provider.name}
callbackUrl={searchParams?.callbackUrl}
redirectTo={searchParams?.redirectTo}
/>
) : null,
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function OTPForm({ email }: { email: string }) {
message: t("wrongVerificationCode"),
});
} else {
window.location.href = searchParams?.get("callbackUrl") ?? "/";
window.location.href = searchParams?.get("redirectTo") ?? "/";
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function OTPForm({ token }: { token: string }) {

signIn("registration-token", {
token,
redirectTo: searchParams?.get("callbackUrl") ?? "/",
redirectTo: searchParams?.get("redirectTo") ?? "/",
});
});

Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/app/api/user/verify-email-change/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const GET = async (request: NextRequest) => {

if (!session?.user || !session.user.email) {
return NextResponse.redirect(
new URL(`/login?callbackUrl=${request.url}`, request.url),
new URL(`/login?redirectTo=${request.url}`, request.url),
);
}

Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/login-link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const LoginLink = React.forwardRef<
<Link
ref={ref}
{...props}
href={`/login?callbackUrl=${encodeURIComponent(pathname)}`}
href={`/login?redirectTo=${encodeURIComponent(pathname)}`}
>
{children}
</Link>
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/register-link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const RegisterLink = React.forwardRef<
onClick={async (e) => {
e.preventDefault();
props.onClick?.(e);
router.push("/register?callbackUrl=" + encodeURIComponent(pathname));
router.push("/register?redirectTo=" + encodeURIComponent(pathname));
}}
>
{children}
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default auth(async (req) => {
!publicRoutes.some((route) => newUrl.pathname.startsWith(route))
) {
if (newUrl.pathname !== "/") {
newUrl.searchParams.set("callbackUrl", newUrl.pathname);
newUrl.searchParams.set("redirectTo", newUrl.pathname);
}
newUrl.pathname = "/login";
return NextResponse.redirect(newUrl);
Expand Down
2 changes: 1 addition & 1 deletion apps/web/tests/create-delete-poll.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ test.describe.serial(() => {

deletePollDialog.getByRole("button", { name: "delete" }).click();

await expect(page).toHaveURL("/login?callbackUrl=%2Fpolls");
await expect(page).toHaveURL("/login?redirectTo=%2Fpolls");
});
});

0 comments on commit 7b0acd9

Please sign in to comment.