-
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
teachmetw
committed
Sep 10, 2023
1 parent
da4b245
commit 8b2e61d
Showing
186 changed files
with
216 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,8 +8,8 @@ DATABASE_URL="mongodb+srv://srobinleeteachmetw:[email protected]/ | |
NEXTAUTH_JWT_SECRET = "NEXT-JWT-SECRET" | ||
NEXTAUTH_SECRET = "NEXT-SECRET" | ||
|
||
GITHUB_ID= | ||
GITHUB_SECRET= | ||
GITHUB_ID=20dc8cad4e7d2c47f74f | ||
GITHUB_SECRET=90242f16b4c90393182b16d3c79718e764d18a77 | ||
|
||
GOOGLE_CLIENT_ID= | ||
GOOGLE_CLIENT_SECRET= | ||
GOOGLE_CLIENT_ID=1060281056257-2ovriqqpaamj9l8i1jehu3jfr1bmp985.apps.googleusercontent.com | ||
GOOGLE_CLIENT_SECRET=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 |
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 @@ | ||
import useSwr from 'swr' | ||
|
||
import fetcher from '@/lib/fetcher'; | ||
|
||
const useCurrentUser = () => { | ||
const { data, error, isLoading, mutate } = useSwr('/api/current', fetcher); | ||
return { | ||
data, | ||
error, | ||
isLoading, | ||
mutate, | ||
} | ||
}; | ||
|
||
export default useCurrentUser; |
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,5 @@ | ||
import axios from 'axios'; | ||
|
||
const fetcher = (url: string) => axios.get(url).then(res => res.data); | ||
|
||
export default fetcher; |
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,27 @@ | ||
import { NextApiRequest, NextApiResponse } from "next"; | ||
import { getServerSession } from "next-auth"; | ||
|
||
import prismadb from "@/lib/prismadb"; | ||
import { authOptions } from "@/pages/api/auth/[...nextauth]"; | ||
|
||
const serverAuth = async (req: NextApiRequest, res: NextApiResponse) => { | ||
const session = await getServerSession(req, res, authOptions); | ||
|
||
if (!session?.user?.email) { | ||
throw new Error('Not signed in'); | ||
} | ||
|
||
const currentUser = await prismadb.user.findUnique({ | ||
where: { | ||
email: session.user.email, | ||
} | ||
}); | ||
|
||
if (!currentUser) { | ||
throw new Error('Not signed in'); | ||
} | ||
|
||
return { currentUser }; | ||
} | ||
|
||
export default serverAuth; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,17 @@ | ||
import { NextApiRequest, NextApiResponse } from "next"; | ||
import serverAuth from "@/lib/serverAuth"; | ||
|
||
export default async function handler(req: NextApiRequest, res: NextApiResponse) { | ||
try { | ||
if (req.method !== 'GET') { | ||
return res.status(405).end(); | ||
} | ||
|
||
const { currentUser } = await serverAuth(req, res); | ||
|
||
return res.status(200).json(currentUser); | ||
} catch (error) { | ||
console.log(error); | ||
return res.status(500).end(); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,7 +1,31 @@ | ||
import useCurrentUser from '@/hooks/useCurrentUser'; | ||
import { NextPageContext } from 'next'; | ||
import { getSession, signOut } from 'next-auth/react'; | ||
|
||
export async function getServerSideProps(context: NextPageContext) { | ||
const session = await getSession(context); | ||
if (!session) { | ||
return { | ||
redirect: { | ||
destination: '/auth', | ||
permanent: false, | ||
}, | ||
}; | ||
} | ||
return { | ||
props: {}, | ||
}; | ||
} | ||
|
||
export default function Home() { | ||
const { data: user } = useCurrentUser(); | ||
return ( | ||
<> | ||
<h1 className="text-2xl text-blue-500"> | ||
Hello world! | ||
</h1> | ||
<p> Logged in as {user?.email}</p> | ||
<button onClick={() => signOut()}>Sign out</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { NextPageContext } from 'next'; | ||
import { getSession } from 'next-auth/react'; | ||
import useCurrentUser from '@/hooks/useCurrentUser'; | ||
|
||
|
||
export async function getServerSideProps(context: NextPageContext) { | ||
const session = await getSession(context); | ||
if (!session) { | ||
return { | ||
redirect: { | ||
destination: '/auth', | ||
permanent: false, | ||
}, | ||
}; | ||
} | ||
return { | ||
props: {}, | ||
}; | ||
} | ||
|
||
const Profiles = () => { | ||
|
||
const { data: user } = useCurrentUser(); | ||
|
||
return ( | ||
<div className='flex items-center h-full justify-center'> | ||
<div className='flex flex-col'> | ||
<h1 className='text-3xl md:text-6xl text-center text-white'>Who is using?</h1> | ||
<div className='flex items-center justify-center gap-8 mt-10'> | ||
<div onClick={() => {}}> | ||
<div className='group flex-row w-44 mx-auto'> | ||
<div className=' | ||
w-44 | ||
h-44 | ||
rounded-md | ||
flex | ||
items-center | ||
justify-center | ||
border-2 | ||
border-transparent | ||
group-hover:cursor-pointer | ||
group-hover:border-white | ||
overflow-hidden'> | ||
<img src='/images/profiles/5992.png' alt="Profile"></img> | ||
</div> | ||
<div className=' | ||
mt-4 | ||
text-gray-400 | ||
text-2xl | ||
text-center | ||
group-hover:text-white | ||
'> | ||
{user?.name} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
}; | ||
|
||
export default Profiles; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.