File tree 5 files changed +61
-12
lines changed
5 files changed +61
-12
lines changed Original file line number Diff line number Diff line change 1
- DATABASE_URL = " postgresql://postgres:example@localhost:5432/postgres"
1
+ DATABASE_URL = " postgresql://postgres:example@localhost:5432/postgres"
2
+
3
+ # Next Auth Discord Provider
4
+ GITHUB_CLIENT_ID = " "
5
+ GITHUB_CLIENT_SECRET = " "
6
+
7
+ NEXTAUTH_SECRET = " my_ultra_secure_nextauth_secret"
8
+ NEXTAUTH_URL = " http://localhost:3000"
Original file line number Diff line number Diff line change 1
1
/** @type {import('next').NextConfig } */
2
- const nextConfig = { }
2
+ const nextConfig = {
3
+ images : { domains : [ 'avatars.githubusercontent.com' ] }
4
+ }
3
5
4
6
module . exports = nextConfig
Original file line number Diff line number Diff line change @@ -4,8 +4,8 @@ import GithubProvider from "next-auth/providers/github";
4
4
const handler = NextAuth ( {
5
5
providers : [
6
6
GithubProvider ( {
7
- clientId : "setup-with-community" ,
8
- clientSecret : "setup-with-community" ,
7
+ clientId : process . env . GITHUB_CLIENT_ID ! ,
8
+ clientSecret : process . env . GITHUB_CLIENT_SECRET ! ,
9
9
} ) ,
10
10
] ,
11
11
} ) ;
Original file line number Diff line number Diff line change 1
1
import { Button } from "@/components/ui/button" ;
2
+ import { LoginButton , LogoutButton } from "@/components/ui/buttons" ;
2
3
import { prisma } from "@/lib/prisma" ;
4
+ import { getServerSession } from "next-auth" ;
5
+ import Image from "next/image" ;
3
6
4
7
export default async function Home ( ) {
5
- const users = await prisma . user . findMany ( ) ;
6
- console . log ( users ) ;
7
-
8
- return (
9
- < main className = "flex min-h-screen flex-col items-center justify-between p-24" >
10
- < Button > Button</ Button >
11
- </ main >
12
- ) ;
8
+ const users = await prisma . user . findMany ( ) ;
9
+ console . log ( users ) ;
10
+ const session = await getServerSession ( ) ;
11
+ return (
12
+ < main className = "flex min-h-screen flex-col items-center justify-between p-24" >
13
+ < Button > Button</ Button >
14
+ { session ? (
15
+ < div className = "flex space-x-2 items-center" >
16
+ < Image
17
+ className = "rounded-full"
18
+ src = { session ?. user ?. image ! }
19
+ alt = "user avatar"
20
+ height = { 40 }
21
+ width = { 40 }
22
+ />
23
+ < p className = "text-gray-700 font-bold" >
24
+ { session ?. user ?. name }
25
+ </ p >
26
+ < LogoutButton />
27
+ </ div >
28
+ ) : (
29
+ < LoginButton />
30
+ ) }
31
+ </ main >
32
+ ) ;
13
33
}
Original file line number Diff line number Diff line change
1
+ "use client" ;
2
+
3
+ import { signIn , signOut } from "next-auth/react" ;
4
+ import { Button } from "./button" ;
5
+
6
+ export const LoginButton = ( ) => {
7
+ return (
8
+ < Button onClick = { ( ) => signIn ( ) } >
9
+ Sign in
10
+ </ Button >
11
+ ) ;
12
+ } ;
13
+
14
+ export const LogoutButton = ( ) => {
15
+ return (
16
+ < Button onClick = { ( ) => signOut ( ) } >
17
+ Sign Out
18
+ </ Button >
19
+ ) ;
20
+ } ;
You can’t perform that action at this time.
0 commit comments