Skip to content

Commit

Permalink
Riot Logos added
Browse files Browse the repository at this point in the history
  • Loading branch information
teachmetw committed Sep 10, 2023
1 parent da4b245 commit 8b2e61d
Show file tree
Hide file tree
Showing 186 changed files with 216 additions and 18 deletions.
8 changes: 4 additions & 4 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -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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
15 changes: 15 additions & 0 deletions hooks/useCurrentUser.ts
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;
5 changes: 5 additions & 0 deletions lib/fetcher.ts
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;
27 changes: 27 additions & 0 deletions lib/serverAuth.ts
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;
21 changes: 21 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"react": "18.2.0",
"react-dom": "18.2.0",
"react-icons": "^4.11.0",
"swr": "^2.2.2",
"typescript": "5.2.2"
},
"devDependencies": {
Expand Down
17 changes: 17 additions & 0 deletions pages/api/current.ts
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();
}
}
53 changes: 39 additions & 14 deletions pages/auth.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,31 @@
import Input from "@/components/input";
import axios from "axios";
import { useCallback, useState } from "react"
import { signIn } from "next-auth/react";
import { signIn, getSession } from "next-auth/react";
import { useRouter } from "next/router";

import { NextPageContext } from 'next';
import { FcGoogle } from 'react-icons/fc';
import { FaGithub } from 'react-icons/fa';


export async function getServerSideProps(context: NextPageContext) {
const session = await getSession(context);

if (session) {
return {
redirect: {
destination: '/',
permanent: false,
}
}
}

return {
props: {}
}
}


const Auth = () => {
const router = useRouter();
const [email, setEmail] = useState('');
Expand All @@ -28,24 +47,25 @@ const Auth = () => {
callbackUrl: '/'
});

router.push('/');
router.push('/profiles');
} catch (error) {
console.log(error);
}
}, [email, password, router]);

const register = useCallback(async () => {
const register = useCallback(async () => {
try {
await axios.post('/api/auth/register', {
email,
name,
password
});
login();
await axios.post('/api/register', {
email,
name,
password
});

login();
} catch (error) {
console.log(error);
}
}, [email, name, password, login])
}, [email, name, password, login]);



Expand Down Expand Up @@ -89,7 +109,9 @@ const Auth = () => {
</button>

<div className="flex flex-row items-center gap-4 mt-8 justify-center">
<div className="
<div
onClick={() => signIn('google', { callbackUrl: '/profiles' })}
className="
w-10
h-10
bg-white
Expand All @@ -102,7 +124,10 @@ const Auth = () => {
transition">
<FcGoogle size={30} />
</div>
<div className="
<div

onClick={() => signIn('github', { callbackUrl: '/profiles' })}
className="
w-10
h-10
bg-white
Expand Down
24 changes: 24 additions & 0 deletions pages/index.tsx
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>
</>
)
}
63 changes: 63 additions & 0 deletions pages/profiles.tsx
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;
Binary file added public/images/profiles/5992.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/profiles/5993.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/profiles/5994.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/profiles/5995.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/profiles/5996.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/profiles/5997.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/profiles/5998.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/profiles/5999.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/profiles/6000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/profiles/6001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/profiles/6002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/profiles/6003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/profiles/6004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/profiles/6005.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/profiles/6006.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/profiles/6007.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/profiles/6008.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/profiles/6009.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/profiles/6010.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/profiles/6011.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/profiles/6012.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/profiles/6013.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/profiles/6014.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/profiles/6015.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/profiles/6016.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/profiles/6017.png
Binary file added public/images/profiles/6018.png
Binary file added public/images/profiles/6019.png
Binary file added public/images/profiles/6020.png
Binary file added public/images/profiles/6021.png
Binary file added public/images/profiles/6022.png
Binary file added public/images/profiles/6023.png
Binary file added public/images/profiles/6024.png
Binary file added public/images/profiles/6025.png
Binary file added public/images/profiles/6026.png
Binary file added public/images/profiles/6027.png
Binary file added public/images/profiles/6028.png
Binary file added public/images/profiles/6029.png
Binary file added public/images/profiles/6030.png
Binary file added public/images/profiles/6031.png
Binary file added public/images/profiles/6032.png
Binary file added public/images/profiles/6033.png
Binary file added public/images/profiles/6034.png
Binary file added public/images/profiles/6035.png
Binary file added public/images/profiles/6036.png
Binary file added public/images/profiles/6037.png
Binary file added public/images/profiles/6038.png
Binary file added public/images/profiles/6039.png
Binary file added public/images/profiles/6040.png
Binary file added public/images/profiles/6041.png
Binary file added public/images/profiles/6042.png
Binary file added public/images/profiles/6043.png
Binary file added public/images/profiles/6044.png
Binary file added public/images/profiles/6045.png
Binary file added public/images/profiles/6046.png
Binary file added public/images/profiles/6047.png
Binary file added public/images/profiles/6048.png
Binary file added public/images/profiles/6049.png
Binary file added public/images/profiles/6050.png
Binary file added public/images/profiles/6051.png
Binary file added public/images/profiles/6052.png
Binary file added public/images/profiles/6053.png
Binary file added public/images/profiles/6054.png
Binary file added public/images/profiles/6055.png
Binary file added public/images/profiles/6056.png
Binary file added public/images/profiles/6057.png
Binary file added public/images/profiles/6058.png
Binary file added public/images/profiles/6059.png
Binary file added public/images/profiles/6060.png
Binary file added public/images/profiles/6061.png
Binary file added public/images/profiles/6062.png
Binary file added public/images/profiles/6063.png
Binary file added public/images/profiles/6064.png
Binary file added public/images/profiles/6065.png
Binary file added public/images/profiles/6066.png
Binary file added public/images/profiles/6067.png
Binary file added public/images/profiles/6068.png
Binary file added public/images/profiles/6069.png
Binary file added public/images/profiles/6070.png
Binary file added public/images/profiles/6071.png
Binary file added public/images/profiles/6072.png
Binary file added public/images/profiles/6073.png
Binary file added public/images/profiles/6074.png
Binary file added public/images/profiles/6075.png
Binary file added public/images/profiles/6076.png
Binary file added public/images/profiles/6077.png
Binary file added public/images/profiles/6078.png
Binary file added public/images/profiles/6079.png
Binary file added public/images/profiles/6080.png
Binary file added public/images/profiles/6081.png
Binary file added public/images/profiles/6082.png
Binary file added public/images/profiles/6083.png
Binary file added public/images/profiles/6084.png
Binary file added public/images/profiles/6085.png
Binary file added public/images/profiles/6086.png
Binary file added public/images/profiles/6087.png
Binary file added public/images/profiles/6088.png
Binary file added public/images/profiles/6089.png
Binary file added public/images/profiles/6090.png
Binary file added public/images/profiles/6091.png
Binary file added public/images/profiles/6092.png
Binary file added public/images/profiles/6093.png
Binary file added public/images/profiles/6094.png
Binary file added public/images/profiles/6095.png
Binary file added public/images/profiles/6096.png
Binary file added public/images/profiles/6097.png
Binary file added public/images/profiles/6098.png
Binary file added public/images/profiles/6099.png
Binary file added public/images/profiles/6100.png
Binary file added public/images/profiles/6101.png
Binary file added public/images/profiles/6102.png
Binary file added public/images/profiles/6103.png
Binary file added public/images/profiles/6104.png
Binary file added public/images/profiles/6105.png
Binary file added public/images/profiles/6106.png
Binary file added public/images/profiles/6107.png
Binary file added public/images/profiles/6108.png
Binary file added public/images/profiles/6109.png
Binary file added public/images/profiles/6200.png
Binary file added public/images/profiles/6201.png
Binary file added public/images/profiles/6202.png
Binary file added public/images/profiles/6203.png
Binary file added public/images/profiles/6204.png
Binary file added public/images/profiles/6205.png
Binary file added public/images/profiles/6206.png
Binary file added public/images/profiles/6207.png
Binary file added public/images/profiles/6208.png
Binary file added public/images/profiles/6209.png
Binary file added public/images/profiles/6210.png
Binary file added public/images/profiles/6211.png
Binary file added public/images/profiles/6212.png
Binary file added public/images/profiles/6213.png
Binary file added public/images/profiles/6214.png
Binary file added public/images/profiles/6215.png
Binary file added public/images/profiles/6216.png
Binary file added public/images/profiles/6217.png
Binary file added public/images/profiles/6218.png
Binary file added public/images/profiles/6219.png
Binary file added public/images/profiles/6220.png
Binary file added public/images/profiles/6221.png
Binary file added public/images/profiles/6222.png
Binary file added public/images/profiles/6223.png
Binary file added public/images/profiles/6224.png
Binary file added public/images/profiles/6225.png
Binary file added public/images/profiles/6226.png
Binary file added public/images/profiles/6227.png
Binary file added public/images/profiles/6228.png
Binary file added public/images/profiles/6229.png
Binary file added public/images/profiles/6230.png
Binary file added public/images/profiles/6231.png
Binary file added public/images/profiles/6232.png
Binary file added public/images/profiles/6233.png
Binary file added public/images/profiles/6234.png
Binary file added public/images/profiles/6235.png
Binary file added public/images/profiles/6236.png
Binary file added public/images/profiles/6237.png
Binary file added public/images/profiles/6238.png
Binary file added public/images/profiles/6239.png
Binary file added public/images/profiles/6240.png
Binary file added public/images/profiles/6241.png
Binary file added public/images/profiles/6242.png
Binary file added public/images/profiles/6243.png
Binary file added public/images/profiles/6244.png
Binary file added public/images/profiles/6246.png
Binary file added public/images/profiles/6247.png
Binary file added public/images/profiles/6248.png
Binary file added public/images/profiles/6249.png
Binary file added public/images/profiles/6250.png
Binary file added public/images/profiles/6251.png
Binary file added public/images/profiles/6252.png
Binary file added public/images/profiles/6253.png
Binary file added public/images/profiles/6254.png
Binary file added public/images/profiles/6255.png
Binary file added public/images/profiles/6256.png
Binary file added public/images/profiles/6257.png
Binary file added public/images/profiles/6258.png

0 comments on commit 8b2e61d

Please sign in to comment.