mirror of
https://github.com/lukevella/rallly.git
synced 2025-04-28 17:56:37 +02:00
⚡️ Cache login page
This commit is contained in:
parent
ca46b18f3a
commit
a40f86024e
3 changed files with 11 additions and 25 deletions
|
@ -1,21 +1,17 @@
|
||||||
"use client";
|
"use client";
|
||||||
import { Button } from "@rallly/ui/button";
|
import { Button } from "@rallly/ui/button";
|
||||||
|
import { useSearchParams } from "next/navigation";
|
||||||
import { signIn } from "next-auth/react";
|
import { signIn } from "next-auth/react";
|
||||||
|
|
||||||
import { Trans } from "@/components/trans";
|
import { Trans } from "@/components/trans";
|
||||||
|
|
||||||
export async function LoginWithOIDC({
|
export async function LoginWithOIDC({ name }: { name: string }) {
|
||||||
name,
|
const searchParams = useSearchParams();
|
||||||
redirectTo,
|
|
||||||
}: {
|
|
||||||
name: string;
|
|
||||||
redirectTo?: string;
|
|
||||||
}) {
|
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
signIn("oidc", {
|
signIn("oidc", {
|
||||||
redirectTo,
|
redirectTo: searchParams?.get("redirectTo") ?? undefined,
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
variant="link"
|
variant="link"
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { Button } from "@rallly/ui/button";
|
||||||
import { Icon } from "@rallly/ui/icon";
|
import { Icon } from "@rallly/ui/icon";
|
||||||
import { UserIcon } from "lucide-react";
|
import { UserIcon } from "lucide-react";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
|
import { useSearchParams } from "next/navigation";
|
||||||
import { signIn } from "next-auth/react";
|
import { signIn } from "next-auth/react";
|
||||||
|
|
||||||
import { Trans } from "@/components/trans";
|
import { Trans } from "@/components/trans";
|
||||||
|
@ -40,13 +41,12 @@ function SSOImage({ provider }: { provider: string }) {
|
||||||
export function SSOProvider({
|
export function SSOProvider({
|
||||||
providerId,
|
providerId,
|
||||||
name,
|
name,
|
||||||
redirectTo,
|
|
||||||
}: {
|
}: {
|
||||||
providerId: string;
|
providerId: string;
|
||||||
name: string;
|
name: string;
|
||||||
redirectTo?: string;
|
|
||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const searchParams = useSearchParams();
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
size="lg"
|
size="lg"
|
||||||
|
@ -58,7 +58,7 @@ export function SSOProvider({
|
||||||
key={providerId}
|
key={providerId}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
signIn(providerId, {
|
signIn(providerId, {
|
||||||
redirectTo,
|
redirectTo: searchParams?.get("redirectTo") ?? undefined,
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|
|
@ -20,13 +20,9 @@ import { LoginWithOIDC } from "./components/login-with-oidc";
|
||||||
import { OrDivider } from "./components/or-divider";
|
import { OrDivider } from "./components/or-divider";
|
||||||
import { SSOProvider } from "./components/sso-provider";
|
import { SSOProvider } from "./components/sso-provider";
|
||||||
|
|
||||||
export default async function LoginPage({
|
export const dynamic = "force-static";
|
||||||
searchParams,
|
|
||||||
}: {
|
export default async function LoginPage() {
|
||||||
searchParams?: {
|
|
||||||
redirectTo?: string;
|
|
||||||
};
|
|
||||||
}) {
|
|
||||||
const { t } = await getTranslation();
|
const { t } = await getTranslation();
|
||||||
|
|
||||||
const oidcProvider = OIDCProvider();
|
const oidcProvider = OIDCProvider();
|
||||||
|
@ -51,12 +47,7 @@ export default async function LoginPage({
|
||||||
<AuthPageContent>
|
<AuthPageContent>
|
||||||
<LoginWithEmailForm />
|
<LoginWithEmailForm />
|
||||||
{hasAlternateLoginMethods ? <OrDivider /> : null}
|
{hasAlternateLoginMethods ? <OrDivider /> : null}
|
||||||
{oidcProvider ? (
|
{oidcProvider ? <LoginWithOIDC name={oidcProvider.name} /> : null}
|
||||||
<LoginWithOIDC
|
|
||||||
name={oidcProvider.name}
|
|
||||||
redirectTo={searchParams?.redirectTo}
|
|
||||||
/>
|
|
||||||
) : null}
|
|
||||||
{socialProviders ? (
|
{socialProviders ? (
|
||||||
<div className="grid gap-4">
|
<div className="grid gap-4">
|
||||||
{socialProviders.map((provider) =>
|
{socialProviders.map((provider) =>
|
||||||
|
@ -65,7 +56,6 @@ export default async function LoginPage({
|
||||||
key={provider.id}
|
key={provider.id}
|
||||||
providerId={provider.id}
|
providerId={provider.id}
|
||||||
name={provider.options?.name || provider.name}
|
name={provider.options?.name || provider.name}
|
||||||
redirectTo={searchParams?.redirectTo}
|
|
||||||
/>
|
/>
|
||||||
) : null,
|
) : null,
|
||||||
)}
|
)}
|
||||||
|
|
Loading…
Add table
Reference in a new issue