Spaces:
Running
Running
redirect to siginin with callback URL
Browse files- app/(public)/signin/page.tsx +6 -17
- app/[owner]/[repoId]/page.tsx +7 -4
- app/new/page.tsx +1 -1
- components/login/login-buttons.tsx +15 -0
app/(public)/signin/page.tsx
CHANGED
|
@@ -1,16 +1,12 @@
|
|
| 1 |
-
|
| 2 |
-
import { signIn } from "next-auth/react";
|
| 3 |
-
import Image from "next/image";
|
| 4 |
|
| 5 |
-
|
| 6 |
-
import HFLogo from "@/assets/hf-logo.svg";
|
| 7 |
-
|
| 8 |
-
export default function SignInPage({
|
| 9 |
searchParams,
|
| 10 |
}: {
|
| 11 |
-
searchParams: { callbackUrl: string };
|
| 12 |
}) {
|
| 13 |
-
const { callbackUrl } = searchParams;
|
|
|
|
| 14 |
return (
|
| 15 |
<section className="min-h-screen font-sans">
|
| 16 |
<div className="px-6 py-16 max-w-5xl mx-auto text-center">
|
|
@@ -18,14 +14,7 @@ export default function SignInPage({
|
|
| 18 |
<p className="text-lg text-muted-foreground mb-8">
|
| 19 |
You can't access this resource without being signed in.
|
| 20 |
</p>
|
| 21 |
-
<
|
| 22 |
-
onClick={() =>
|
| 23 |
-
signIn("huggingface", { callbackUrl: callbackUrl ?? "/deepsite" })
|
| 24 |
-
}
|
| 25 |
-
>
|
| 26 |
-
<Image src={HFLogo} alt="Hugging Face" width={20} height={20} />
|
| 27 |
-
Sign in with Hugging Face
|
| 28 |
-
</Button>
|
| 29 |
</div>
|
| 30 |
</section>
|
| 31 |
);
|
|
|
|
| 1 |
+
import { LoginButtons } from "@/components/login/login-buttons";
|
|
|
|
|
|
|
| 2 |
|
| 3 |
+
export default async function SignInPage({
|
|
|
|
|
|
|
|
|
|
| 4 |
searchParams,
|
| 5 |
}: {
|
| 6 |
+
searchParams: Promise<{ callbackUrl: string }>;
|
| 7 |
}) {
|
| 8 |
+
const { callbackUrl } = await searchParams;
|
| 9 |
+
console.log(callbackUrl);
|
| 10 |
return (
|
| 11 |
<section className="min-h-screen font-sans">
|
| 12 |
<div className="px-6 py-16 max-w-5xl mx-auto text-center">
|
|
|
|
| 14 |
<p className="text-lg text-muted-foreground mb-8">
|
| 15 |
You can't access this resource without being signed in.
|
| 16 |
</p>
|
| 17 |
+
<LoginButtons callbackUrl={callbackUrl ?? "/deepsite"} />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
</div>
|
| 19 |
</section>
|
| 20 |
);
|
app/[owner]/[repoId]/page.tsx
CHANGED
|
@@ -12,12 +12,15 @@ export default async function ProjectPage({
|
|
| 12 |
}) {
|
| 13 |
const session = await auth();
|
| 14 |
|
| 15 |
-
if (!session) {
|
| 16 |
-
redirect("/api/auth/signin");
|
| 17 |
-
}
|
| 18 |
-
|
| 19 |
const { owner, repoId } = await params;
|
| 20 |
const { commit } = await searchParams;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
const datas = await getProject(`${owner}/${repoId}`, commit);
|
| 22 |
if (!datas?.project) {
|
| 23 |
return notFound();
|
|
|
|
| 12 |
}) {
|
| 13 |
const session = await auth();
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
const { owner, repoId } = await params;
|
| 16 |
const { commit } = await searchParams;
|
| 17 |
+
if (!session) {
|
| 18 |
+
redirect(
|
| 19 |
+
`/api/auth/signin?callbackUrl=/deepsite/${owner}/${repoId}${
|
| 20 |
+
commit ? `?commit=${commit}` : ""
|
| 21 |
+
}`
|
| 22 |
+
);
|
| 23 |
+
}
|
| 24 |
const datas = await getProject(`${owner}/${repoId}`, commit);
|
| 25 |
if (!datas?.project) {
|
| 26 |
return notFound();
|
app/new/page.tsx
CHANGED
|
@@ -10,7 +10,7 @@ export default async function NewProjectPage({
|
|
| 10 |
const session = await auth();
|
| 11 |
|
| 12 |
if (!session) {
|
| 13 |
-
redirect("/api/auth/signin");
|
| 14 |
}
|
| 15 |
|
| 16 |
const { prompt } = await searchParams;
|
|
|
|
| 10 |
const session = await auth();
|
| 11 |
|
| 12 |
if (!session) {
|
| 13 |
+
redirect("/api/auth/signin?callbackUrl=/deepsite/new");
|
| 14 |
}
|
| 15 |
|
| 16 |
const { prompt } = await searchParams;
|
components/login/login-buttons.tsx
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client";
|
| 2 |
+
import { signIn } from "next-auth/react";
|
| 3 |
+
import Image from "next/image";
|
| 4 |
+
|
| 5 |
+
import { Button } from "@/components/ui/button";
|
| 6 |
+
import HFLogo from "@/assets/hf-logo.svg";
|
| 7 |
+
|
| 8 |
+
export const LoginButtons = ({ callbackUrl }: { callbackUrl: string }) => {
|
| 9 |
+
return (
|
| 10 |
+
<Button onClick={() => signIn("huggingface", { callbackUrl })}>
|
| 11 |
+
<Image src={HFLogo} alt="Hugging Face" width={20} height={20} />
|
| 12 |
+
Sign in with Hugging Face
|
| 13 |
+
</Button>
|
| 14 |
+
);
|
| 15 |
+
};
|