From e7c6271322cef648b3d6de59360d37dcb881b723 Mon Sep 17 00:00:00 2001 From: Aarnav Tale Date: Wed, 15 May 2024 21:54:02 -0400 Subject: [PATCH] chore: cleanup login page --- app/routes/login.tsx | 126 +++++++++++++++++++++++-------------------- 1 file changed, 67 insertions(+), 59 deletions(-) diff --git a/app/routes/login.tsx b/app/routes/login.tsx index b5e725b..b095974 100644 --- a/app/routes/login.tsx +++ b/app/routes/login.tsx @@ -18,8 +18,8 @@ export async function loader({ request }: LoaderFunctionArgs) { return redirect('/machines', { headers: { // eslint-disable-next-line @typescript-eslint/naming-convention - 'Set-Cookie': await commitSession(session) - } + 'Set-Cookie': await commitSession(session), + }, }) } @@ -35,7 +35,7 @@ export async function loader({ request }: LoaderFunctionArgs) { const data = { oidc: issuer, - apiKey: normal === undefined + apiKey: normal === undefined, } if (!data.oidc && !data.apiKey) { @@ -82,21 +82,21 @@ export async function action({ request }: ActionFunctionArgs) { session.set('hsApiKey', apiKey) session.set('user', { name: key.prefix, - email: `${expiresDays} days` + email: `${expiresDays.toString()} days`, }) return redirect('/machines', { headers: { // eslint-disable-next-line @typescript-eslint/naming-convention 'Set-Cookie': await commitSession(session, { - maxAge: expiresIn - }) - } + maxAge: expiresIn, + }), + }, }) } catch (error) { console.error(error) return json({ - error: 'Invalid API key' + error: 'Invalid API key', }) } } @@ -107,61 +107,69 @@ export default function Page() { const showOr = useMemo(() => data.oidc && data.apiKey, [data]) return ( -
- +
+ Welcome to Headplane - {data.apiKey ? ( -
- - Enter an API key to authenticate with Headplane. You can generate - one by running - {' '} - - headscale apikeys create - - {' '} - in your terminal. - + {data.apiKey + ? ( + + + Enter an API key to authenticate with Headplane. You can generate + one by running + {' '} + + headscale apikeys create + + {' '} + in your terminal. + - {actionData?.error ? ( -

{actionData.error}

- ) : undefined} - - - - ) : undefined} - {showOr ? ( -
-
- or -
-
- ) : undefined} - {data.oidc ? ( -
- - -
- ) : undefined} + {actionData?.error + ? ( +

{actionData.error}

+ ) + : undefined} + + + + ) + : undefined} + {showOr + ? ( +
+
+ or +
+
+ ) + : undefined} + {data.oidc + ? ( +
+ + +
+ ) + : undefined}
)