Skip to content

Commit

Permalink
making progress on auth
Browse files Browse the repository at this point in the history
  • Loading branch information
C4illin committed Oct 21, 2024
1 parent b9d2f06 commit ff0a1f0
Show file tree
Hide file tree
Showing 6 changed files with 210 additions and 31 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts
/.env
3 changes: 3 additions & 0 deletions app/api/auth/[...nextauth]/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { handlers } from "@/auth"; // Referring to the auth.ts we just created

export const { GET, POST } = handlers;
81 changes: 51 additions & 30 deletions app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
"use client";

import { signIn } from "next-auth/react";
import Image from "next/image";
import Link from "next/link";



import chs from "../public/chs.png";
import minecraft from "../public/games/minecraft.png";
import gud from "../public/gud-clean.png";


const tenant = "gaming.chs.se";
const product = "gud-gaming";

export default function Home() {
return (
<>
<div
className={`
flex size-full flex-col items-center justify-center bg-gradient-to-r from-slate-950
to-slate-800 pb-20 pt-32
to-slate-800 pb-20 pt-36
`}
>
<h1 className="m-20">
Expand All @@ -21,22 +30,23 @@ export default function Home() {
A part of Chalmers student union
</p>
</h1>
<Link href={"/signup"} className="mb-20">
<button
className={`
relative mb-24 flex flex-row rounded bg-slate-600 px-20 py-4 transition-colors
hover:bg-slate-500
`}
onClick={async (event) => {
event.preventDefault();
signIn("boxyhq-saml", {}, { tenant, product });
}}
>
Get Started
<div
className={`
relative flex flex-row rounded bg-slate-600 px-20 py-4 transition-colors
hover:bg-slate-500
absolute right-6 size-4 translate-y-1 rotate-45 border-r-2 border-t-2 border-slate-200
`}
>
Get Started
<div
className={`
absolute right-6 size-4 translate-y-1 rotate-45 border-r-2 border-t-2
border-slate-200
`}
/>
</div>
</Link>
/>
</button>
<div className="flex w-full flex-row items-center justify-center gap-4">
<Image
src={gud}
Expand All @@ -55,7 +65,7 @@ export default function Home() {
Games offered:
</h2>
<div className="flex flex-row flex-wrap items-center justify-center gap-4">
<div className="h-40 rounded bg-slate-900 p-4">
<div className="h-40 w-64 max-w-full rounded bg-slate-900 p-4">
<Image
src={minecraft}
alt="Minecraft"
Expand All @@ -65,25 +75,36 @@ export default function Home() {
`}
/>
</div>
<div className="h-40 w-64 max-w-full rounded bg-slate-900">
<div
className={`
w-64 max-w-full text-center leading-[10rem] brightness-75 transition-[filter]
hover:brightness-100 hover:grayscale-0
`}
>
And more...
</div>
</div>
</div>
</div>
<div className="flex w-full items-center justify-center">
<Link href={"/signup"} className="mb-20">
<button
className={`
relative mb-20 flex flex-row rounded bg-slate-600 px-20 py-4 transition-colors
hover:bg-slate-500
`}
onClick={async (event) => {
event.preventDefault();
signIn("boxyhq-saml", {}, { tenant, product });
}}
>
Get Started
<div
className={`
relative flex flex-row rounded bg-slate-600 px-20 py-4 transition-colors
hover:bg-slate-500
absolute right-6 size-4 translate-y-1 rotate-45 border-r-2 border-t-2 border-slate-200
`}
>
Get Started
<div
className={`
absolute right-6 size-4 translate-y-1 rotate-45 border-r-2 border-t-2
border-slate-200
`}
/>
</div>
</Link>
/>
</button>
</div>
<footer
className={`
Expand All @@ -101,7 +122,7 @@ export default function Home() {
/>
</Link>

<Link href={"https://chs.chalmers.se"} className="h-16">
<Link href={"https://chs.se"} className="h-16">
<Image
src={chs}
alt="Logo for chalmers student union"
Expand All @@ -114,4 +135,4 @@ export default function Home() {
</footer>
</>
);
}
}
13 changes: 13 additions & 0 deletions auth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import NextAuth from "next-auth";
import BoxyHQ from "next-auth/providers/boxyhq-saml";

export const { handlers, auth, signIn, signOut } = NextAuth({
providers: [
BoxyHQ({
authorization: { params: { scope: "" } }, // This is needed for OAuth 2.0 flow, otherwise default to openid
clientId: process.env.AUTH_BOXYHQ_SAML_ID,
clientSecret: process.env.AUTH_BOXYHQ_SAML_SECRET,
issuer: process.env.AUTH_BOXYHQ_SAML_ISSUER,
}),
],
});
140 changes: 140 additions & 0 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
},
"dependencies": {
"next": "14.2.13",
"next-auth": "^5.0.0-beta.22",
"react": "^18",
"react-dom": "^18",
"sharp": "^0.33.5"
Expand All @@ -32,4 +33,4 @@
"tailwindcss": "^3.4.13",
"typescript": "^5.4.5"
}
}
}

0 comments on commit ff0a1f0

Please sign in to comment.