mirror of
https://github.com/Sosokker/B2D-Ventures.git
synced 2025-12-20 14:34:05 +01:00
Add login-logout button component
This commit is contained in:
parent
d050932cb6
commit
e14ab28185
25
src/components/auth/loginButton.tsx
Normal file
25
src/components/auth/loginButton.tsx
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import Image from "next/image";
|
||||||
|
import { createSupabaseClient } from "@/lib/supabase/clientComponentClient";
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
|
||||||
|
export function LoginButton(props: { nextUrl?: string }) {
|
||||||
|
const supabase = createSupabaseClient();
|
||||||
|
|
||||||
|
const handleLogin = async () => {
|
||||||
|
await supabase.auth.signInWithOAuth({
|
||||||
|
provider: "google",
|
||||||
|
options: {
|
||||||
|
redirectTo: `${location.origin}/auth/callback?next=${props.nextUrl || ""}`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Button className="bg-foreground gap-2 rounded-xl" onClick={handleLogin}>
|
||||||
|
<Image src={"/logo/google.svg"} width={30} height={30} alt={"Google"} />
|
||||||
|
Continue with Google
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
}
|
||||||
16
src/components/auth/logoutButton.tsx
Normal file
16
src/components/auth/logoutButton.tsx
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { createSupabaseClient } from "@/lib/supabase/clientComponentClient";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
|
|
||||||
|
export function LogoutButton() {
|
||||||
|
const supabase = createSupabaseClient();
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
const handleLogout = async () => {
|
||||||
|
await supabase.auth.signOut();
|
||||||
|
router.push("/");
|
||||||
|
};
|
||||||
|
|
||||||
|
return <button onClick={handleLogout}>Logout</button>;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user