Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
serprex committed Nov 24, 2023
1 parent 0f63962 commit 71efee7
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 35 deletions.
39 changes: 37 additions & 2 deletions ui/app/login/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
import Password from '@/components/Password';
'use client';
import Image from 'next/image'
import { useState } from 'react';

export default function Login() { return <Password /> }
import { Button } from '@/lib/Button';
import { TextField } from '@/lib/TextField';
import { Layout, LayoutMain } from '@/lib/Layout';

export default function Password() {
const [pass, setPass] = useState("");
const [error, setError] = useState("");
return (
<Layout>
<LayoutMain alignSelf='center' justifySelf='center' width='xxLarge'>
<Image src="public/images/peerdb-combinedMark.svg" alt="PeerDB" width={512} />
{error && <div style={{
borderRadius:'8px',
fontWeight:'bold',
color:'#600',
backgroundColor:'#c66'
}}>{error}</div>}
Password: <TextField variant='simple' value={pass} onChange={(e: React.ChangeEvent<HTMLInputElement>) => setPass(e.target.value)} />
<Button
onClick={() => {
fetch('/api/login', {
method: 'POST',
body: JSON.stringify({password: pass}),
}).then((res: any) => {
setError(res.error);
});
}}
>
Login
</Button>
</LayoutMain>
</Layout>
);
}
1 change: 0 additions & 1 deletion ui/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Logout from '@/components/Logout';
import Password from '@/components/Password';
import SidebarComponent from '@/components/SidebarComponent';
import { Header } from '@/lib/Header';
import { Layout, LayoutMain } from '@/lib/Layout';
Expand Down
32 changes: 0 additions & 32 deletions ui/components/Password.tsx

This file was deleted.

1 change: 1 addition & 0 deletions ui/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export default function middleware(req: NextRequest) {
if (req.nextUrl.pathname !== '/favicon.ico' &&
req.nextUrl.pathname !== '/login' &&
req.nextUrl.pathname !== '/api/login' &&
!req.nextUrl.pathname.startsWith("/public/") &&
!req.nextUrl.pathname.startsWith("/_next/static/") &&
process.env.PEERDB_PASSWORD &&
req.cookies.get('auth')?.value !== process.env.PEERDB_PASSWORD) {
Expand Down

0 comments on commit 71efee7

Please sign in to comment.