-
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
16 changed files
with
1,436 additions
and
158 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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# G.U.D. Gaming | ||
|
||
Work in progress. | ||
Work in progress. |
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,20 +1,21 @@ | ||
import NextAuth from "next-auth"; | ||
import type { NextAuthOptions } from "next-auth"; | ||
import BoxyHQ from "next-auth/providers/boxyhq-saml"; | ||
|
||
const samlLoginUrl = process.env.AUTH_BOXYHQ_SAML_ISSUER; | ||
|
||
// For more information on each option (and a full list of options) go to | ||
// https://next-auth.js.org/configuration/options | ||
const handler = NextAuth({ | ||
// https://next-auth.js.org/configuration/providers/oauth | ||
|
||
export const authOptions: NextAuthOptions = { | ||
providers: [ | ||
BoxyHQ({ | ||
authorization: { params: { scope: "" } }, | ||
issuer: samlLoginUrl, | ||
issuer: process.env.AUTH_BOXYHQ_SAML_ISSUER, | ||
clientId: process.env.AUTH_BOXYHQ_SAML_ID || "dummy", | ||
clientSecret: process.env.AUTH_BOXYHQ_SAML_SECRET || "dummy", | ||
}), | ||
], | ||
}); | ||
}; | ||
|
||
const handler = NextAuth(authOptions); | ||
|
||
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,30 @@ | ||
"use server"; | ||
|
||
interface MojangResponse { | ||
id: string; | ||
name: string; | ||
} | ||
|
||
export async function register(prevState: any, formData: FormData) { | ||
const username = formData.get("username").toString().toLowerCase(); | ||
|
||
if (!username) { | ||
return { message: "Username is required" }; | ||
} | ||
|
||
const response = await fetch( | ||
`https://api.mojang.com/users/profiles/minecraft/${username}`, | ||
); | ||
|
||
if (response.status === 404 || !response.ok) { | ||
return { message: "Username not found" }; | ||
} | ||
|
||
const uuid = ((await response.json()) as MojangResponse).id; | ||
|
||
if (!uuid) { | ||
return { message: "UUID not found" }; | ||
} | ||
|
||
return { message: "Saved" }; | ||
} |
Empty file.
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,31 @@ | ||
"use client"; | ||
|
||
export function CopyText({ text }: { text: string }) { | ||
return ( | ||
<button | ||
className={`group inline align-text-bottom`} | ||
onClick={async (event) => { | ||
event.preventDefault(); | ||
navigator.clipboard.writeText(text); | ||
}} | ||
> | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
fill="none" | ||
viewBox="0 0 24 24" | ||
strokeWidth={1.5} | ||
stroke="currentColor" | ||
className={` | ||
group size-4 transition-colors | ||
group-hover:text-slate-400 | ||
`} | ||
> | ||
<path | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
d="M15.75 17.25v3.375c0 .621-.504 1.125-1.125 1.125h-9.75a1.125 1.125 0 0 1-1.125-1.125V7.875c0-.621.504-1.125 1.125-1.125H6.75a9.06 9.06 0 0 1 1.5.124m7.5 10.376h3.375c.621 0 1.125-.504 1.125-1.125V11.25c0-4.46-3.243-8.161-7.5-8.876a9.06 9.06 0 0 0-1.5-.124H9.375c-.621 0-1.125.504-1.125 1.125v3.5m7.5 10.375H9.375a1.125 1.125 0 0 1-1.125-1.125v-9.25m12 6.625v-1.875a3.375 3.375 0 0 0-3.375-3.375h-1.5a1.125 1.125 0 0 1-1.125-1.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H9.75" | ||
/> | ||
</svg> | ||
</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
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,46 @@ | ||
"use client"; | ||
|
||
import Form from "next/form"; | ||
import { useActionState } from "react"; | ||
|
||
import { register } from "../api/minecraft/actions"; | ||
import { cn } from "../lib/cn"; | ||
|
||
const initialState = { | ||
message: "", | ||
loading: false, | ||
}; | ||
|
||
export function MinecraftLogin() { | ||
const [state, formAction] = useActionState(register, initialState); | ||
|
||
return ( | ||
<Form action={formAction} className="space-y-2"> | ||
<input | ||
className={` | ||
block w-full rounded border-0 bg-slate-950 p-2 shadow ring-1 ring-inset ring-slate-600 | ||
focus:ring-2 focus:ring-inset focus:ring-slate-600 | ||
placeholder:text-slate-600 | ||
`} | ||
name="username" | ||
id="minecraft-username" | ||
placeholder="Minecraft Username" | ||
/> | ||
<p aria-live="polite">{state?.message}</p> | ||
<button | ||
disabled={state?.loading} | ||
type="submit" | ||
className={cn(` | ||
flex w-full justify-center rounded bg-slate-700 p-2 text-sm/6 font-semibold text-white | ||
shadow | ||
disabled:cursor-wait disabled:bg-slate-800 disabled:text-slate-600 | ||
focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 | ||
focus-visible:outline-slate-600 | ||
hover:bg-slate-500 | ||
`)} | ||
> | ||
Save | ||
</button> | ||
</Form> | ||
); | ||
} |
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,18 @@ | ||
import type { | ||
GetServerSidePropsContext, | ||
NextApiRequest, | ||
NextApiResponse, | ||
} from "next"; | ||
import { getServerSession } from "next-auth"; | ||
|
||
import { authOptions } from "../api/auth/[...nextauth]/route"; | ||
|
||
// Use it in server contexts | ||
export function auth( | ||
...args: | ||
| [GetServerSidePropsContext["req"], GetServerSidePropsContext["res"]] | ||
| [NextApiRequest, NextApiResponse] | ||
| [] | ||
) { | ||
return getServerSession(...args, authOptions); | ||
} |
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
Oops, something went wrong.