github auth

This commit is contained in:
Timur Ercan
2022-12-08 22:42:19 +01:00
parent f0f85ecc27
commit 1101251276
6 changed files with 243 additions and 21 deletions

View File

@ -2,6 +2,7 @@ import { Fragment } from "react";
import { Disclosure, Menu, Transition } from "@headlessui/react";
import Link from "next/link";
import { useRouter } from "next/router";
import { signOut } from "next-auth/react";
import {
Bars3Icon,
@ -24,7 +25,14 @@ const navigation = [
];
const userNavigation = [
{ name: "Your Profile", href: "/settings" },
{ name: "Sign out", href: "/login" },
{
name: "Sign out",
href: "/login",
click: (e: any) => {
e.preventDefault();
signOut();
},
},
];
function classNames(...classes: any) {
@ -127,6 +135,7 @@ export default function Layout({ children }: any) {
{({ active }) => (
<Link
href={item.href}
onClick={item.click}
className={classNames(
active ? "bg-gray-100" : "",
"block px-4 py-2 text-sm text-gray-700"

View File

@ -1,6 +1,7 @@
import { LockClosedIcon } from "@heroicons/react/20/solid";
import Link from "next/link";
import Logo from "./logo";
import { signIn } from "next-auth/react";
export default function Example() {
return (
@ -76,17 +77,21 @@ export default function Example() {
</div>
<div>
<Link href="/dashboard">
<button className="group relative flex w-full justify-center rounded-md border border-transparent bg-neon py-2 px-4 text-sm font-medium text-white hover:bg-neon-dark focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2">
<span className="absolute inset-y-0 left-0 flex items-center pl-3">
<LockClosedIcon
className="h-5 w-5 text-neon-dark group-hover:text-neon"
aria-hidden="true"
/>
</span>
Sign in
</button>
</Link>
<button
onClick={(e) => {
e.preventDefault();
signIn();
}}
className="group relative flex w-full justify-center rounded-md border border-transparent bg-neon py-2 px-4 text-sm font-medium text-white hover:bg-neon-dark focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2"
>
<span className="absolute inset-y-0 left-0 flex items-center pl-3">
<LockClosedIcon
className="h-5 w-5 text-neon-dark group-hover:text-neon"
aria-hidden="true"
/>
</span>
Sign in
</button>
</div>
</form>
</div>