-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
598 additions
and
1,301 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import NextAuth from "next-auth"; | ||
import GoogleProvider from "next-auth/providers/google"; | ||
|
||
const handler = NextAuth({ | ||
providers: [ | ||
GoogleProvider({ | ||
clientId: process.env.GOOGLE_CLIENT_ID_DEV as string, | ||
clientSecret: process.env.GOOGLE_CLIENT_SECRET_DEV as string, | ||
}), | ||
], | ||
callbacks: { | ||
// async signIn({ user, account, profile, email, credentials }) { | ||
// const isAllowedToSignIn = true; | ||
// if (isAllowedToSignIn) { | ||
// return "/"; | ||
// } else { | ||
// // Return false to display a default error message | ||
// return "/"; | ||
// // Or you can return a URL to redirect to: | ||
// // return '/unauthorized' | ||
// } | ||
// }, | ||
// async redirect({ url, baseUrl }) { | ||
// return baseUrl; | ||
// }, | ||
// async session({ session, user, token }) { | ||
// return session; | ||
// }, | ||
// async jwt({ token, user, account }) { | ||
// if (account) { | ||
// token.accessToken = account.access_token; | ||
// } | ||
// return token; | ||
// }, | ||
}, | ||
}); | ||
export { handler as GET, handler as POST }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
"use client"; | ||
|
||
import { SessionProvider } from "next-auth/react"; | ||
|
||
type Props = { | ||
children: React.ReactNode; | ||
}; | ||
|
||
export default function AuthContext({ children }: Props) { | ||
return <SessionProvider>{children}</SessionProvider>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
"use client"; | ||
|
||
import { useSession } from "next-auth/react"; | ||
import Link from "next/link"; | ||
|
||
export default function Header() { | ||
const { data: session, status } = useSession(); | ||
console.log(session); | ||
return ( | ||
<div className="absolute flex flex-row gap-10 right-[32rem]"> | ||
<div>Main</div> | ||
{session ? ( | ||
<div></div> | ||
) : ( | ||
<div> | ||
<Link href={"/login"}>Login</Link> | ||
{/* <Link></Link> */} | ||
</div> | ||
)} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
"use client"; | ||
|
||
import { signIn, useSession } from "next-auth/react"; | ||
import Link from "next/link"; | ||
|
||
export default function Login() { | ||
const { data: session } = useSession(); | ||
return session ? ( | ||
<div> | ||
Already Logged In go back to <Link href={"/"}>Main Page</Link> | ||
</div> | ||
) : ( | ||
<button onClick={() => signIn("google")}>Google LogIn</button> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters