mirror of
https://github.com/Sosokker/B2D-Ventures.git
synced 2025-12-19 05:54:06 +01:00
Add callback and error auth route + rename login to auth path
This commit is contained in:
parent
e14ab28185
commit
12e87c5339
24
src/app/auth/callback/route.ts
Normal file
24
src/app/auth/callback/route.ts
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import { createSupabaseClient } from "@/lib/supabase/serverComponentClient";
|
||||||
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
|
export async function GET(request: Request) {
|
||||||
|
const { searchParams, origin } = new URL(request.url);
|
||||||
|
|
||||||
|
const code = searchParams.get("code");
|
||||||
|
|
||||||
|
// if "next" is in param, use it in the redirect URL
|
||||||
|
const next = searchParams.get("next") ?? "/";
|
||||||
|
|
||||||
|
if (code) {
|
||||||
|
const supabase = createSupabaseClient();
|
||||||
|
|
||||||
|
const { error } = await supabase.auth.exchangeCodeForSession(code);
|
||||||
|
|
||||||
|
if (!error) {
|
||||||
|
return NextResponse.redirect(`${origin}${next}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// return the user to an error page with instructions
|
||||||
|
return NextResponse.redirect(`${origin}/auth/error`);
|
||||||
|
}
|
||||||
3
src/app/auth/error/page.tsx
Normal file
3
src/app/auth/error/page.tsx
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export default function AuthError() {
|
||||||
|
return <div>Authentication Error</div>;
|
||||||
|
}
|
||||||
@ -2,6 +2,9 @@ import Image from "next/image";
|
|||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Card, CardContent, CardFooter, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
import { Card, CardContent, CardFooter, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||||
|
|
||||||
|
import { LoginButton } from "@/components/auth/loginButton";
|
||||||
|
import { LogoutButton } from "@/components/auth/logoutButton";
|
||||||
|
|
||||||
export default function Login() {
|
export default function Login() {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@ -16,14 +19,8 @@ export default function Login() {
|
|||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="flex flex-col gap-y-2 mx-28">
|
<CardContent className="flex flex-col gap-y-2 mx-28">
|
||||||
<p className="self-center font-semibold text-slate-800">Continue With</p>
|
<p className="self-center font-semibold text-slate-800">Continue With</p>
|
||||||
<Button className="bg-foreground gap-2 rounded-xl">
|
<LoginButton />
|
||||||
<Image src={"/logo/google.svg"} width={30} height={30} alt={"Google"} />
|
<LogoutButton />
|
||||||
Continue with Google
|
|
||||||
</Button>
|
|
||||||
<Button className="gap-2 rounded-xl">
|
|
||||||
<Image src={"/logo/facebook.svg"} width={30} height={30} alt={"Google"} />
|
|
||||||
Continue with Facebook
|
|
||||||
</Button>
|
|
||||||
</CardContent>
|
</CardContent>
|
||||||
<CardFooter className="text-xs justify-center">
|
<CardFooter className="text-xs justify-center">
|
||||||
By signing up, you agree to the Terms of Service and acknowledge you’ve read our Privacy Policy.
|
By signing up, you agree to the Terms of Service and acknowledge you’ve read our Privacy Policy.
|
||||||
Loading…
Reference in New Issue
Block a user