forked from ky28059/bctf
-
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.
Merge pull request #4 from ky28059/main
Pull more build error fixes, dep updates
- Loading branch information
Showing
8 changed files
with
225 additions
and
79 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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { NextRequest, NextResponse } from 'next/server'; | ||
import { login } from '@/util/auth'; | ||
|
||
|
||
export async function GET(req: NextRequest) { | ||
const params = req.nextUrl.searchParams; | ||
|
||
const token = params.get('token'); | ||
if (!token) | ||
return NextResponse.redirect(new URL('/login', req.url)); | ||
|
||
const res = await login(token); | ||
if ('error' in res) | ||
return NextResponse.redirect(new URL(`/login?error=${res.error}`, req.url)); | ||
|
||
return NextResponse.redirect(new URL('/profile', req.url)); | ||
} |
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,19 +1,28 @@ | ||
import type { Metadata } from 'next'; | ||
import { redirect } from 'next/navigation'; | ||
|
||
// Components | ||
import LoginContent from '@/app/login/LoginContent'; | ||
|
||
|
||
export const metadata: Metadata = { | ||
title: 'Log in' | ||
} | ||
|
||
export default function Login() { | ||
export default async function Login({ searchParams }: { searchParams: Promise<{ token?: string, error?: string }> }) { | ||
const token = (await searchParams).token; | ||
const error = (await searchParams).error; | ||
|
||
// Automatically sign in if the `token` search parameter is set. | ||
if (token) return redirect(`/login-handler?token=${token}`) | ||
|
||
return ( | ||
<div className="container pt-32 pb-24"> | ||
<h1 className="text-2xl font-bold mb-8 text-center"> | ||
Log in to b01lers internal CTF | ||
</h1> | ||
|
||
<LoginContent /> | ||
<LoginContent error={error} /> | ||
</div> | ||
) | ||
} |
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
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,44 +1,34 @@ | ||
import { Fragment, ReactNode } from 'react'; | ||
import { Dialog, Transition } from '@headlessui/react'; | ||
import type { ReactNode } from 'react'; | ||
import { Dialog, DialogBackdrop, DialogPanel } from '@headlessui/react'; | ||
|
||
|
||
// A reusable component to wrap a transition and dialog overlay around a screen-centered div. | ||
type CenteredModalProps = { | ||
isOpen: boolean, setIsOpen: (isOpen: boolean) => void, | ||
className: string, children: ReactNode | ||
isOpen: boolean, | ||
setIsOpen: (isOpen: boolean) => void, | ||
className: string, | ||
children: ReactNode | ||
} | ||
export default function CenteredModal(props: CenteredModalProps) { | ||
const { isOpen, setIsOpen, className, children } = props; | ||
|
||
return ( | ||
<Transition show={isOpen} as={Fragment}> | ||
<Dialog onClose={() => setIsOpen(false)} className="fixed z-40 inset-0 flex items-center justify-center"> | ||
<Transition.Child | ||
as={Fragment} | ||
enter="ease-out duration-300" | ||
enterFrom="opacity-0" | ||
enterTo="opacity-100" | ||
leave="ease-in duration-200" | ||
leaveFrom="opacity-100" | ||
leaveTo="opacity-0" | ||
> | ||
<div className="fixed inset-0 bg-black/40" /> | ||
</Transition.Child> | ||
<Dialog | ||
className="fixed z-40 inset-0 flex items-center justify-center" | ||
open={isOpen} | ||
onClose={() => setIsOpen(false)} | ||
> | ||
<DialogBackdrop | ||
transition | ||
className="fixed inset-0 bg-black/40 transition duration-300 data-[closed]:duration-200 ease-out data-[closed]:ease-in data-[closed]:opacity-0" | ||
/> | ||
|
||
<Transition.Child | ||
as={Fragment} | ||
enter="ease-out duration-300" | ||
enterFrom="opacity-0 scale-95" | ||
enterTo="opacity-100 scale-100" | ||
leave="ease-in duration-200" | ||
leaveFrom="opacity-100 scale-100" | ||
leaveTo="opacity-0 scale-95" | ||
> | ||
<Dialog.Panel className={className}> | ||
{children} | ||
</Dialog.Panel> | ||
</Transition.Child> | ||
</Dialog> | ||
</Transition> | ||
<DialogPanel | ||
transition | ||
className={className + ' transition duration-300 data-[closed]:duration-200 ease-out data-[closed]:ease-in data-[closed]:scale-95 data-[closed]:opacity-0'} | ||
> | ||
{children} | ||
</DialogPanel> | ||
</Dialog> | ||
) | ||
} |
Oops, something went wrong.