diff --git a/ui/app/api/login/route.ts b/ui/app/api/login/route.ts index 9ae9b961e0..6a6bf202e6 100644 --- a/ui/app/api/login/route.ts +++ b/ui/app/api/login/route.ts @@ -3,7 +3,12 @@ import { cookies } from 'next/headers'; export async function POST(request: Request) { const { password } = await request.json(); if (process.env.PEERDB_PASSWORD !== password) { - return new Response(JSON.stringify({ error: 'wrong password' })); + return new Response( + JSON.stringify({ + error: + 'Your password is incorrect. Please check your password and try again.', + }) + ); } cookies().set('auth', password, { expires: Date.now() + 24 * 60 * 60 * 1000, diff --git a/ui/app/login/page.tsx b/ui/app/login/page.tsx index d158978aab..41c00c0dd8 100644 --- a/ui/app/login/page.tsx +++ b/ui/app/login/page.tsx @@ -4,13 +4,15 @@ import { useRouter, useSearchParams } from 'next/navigation'; import { useState } from 'react'; import { Button } from '@/lib/Button'; -import { Layout, LayoutMain } from '@/lib/Layout'; +import { Icon } from '@/lib/Icon'; +import { Layout } from '@/lib/Layout'; import { TextField } from '@/lib/TextField'; export default function Login() { const router = useRouter(); const searchParams = useSearchParams(); const [pass, setPass] = useState(''); + const [show, setShow] = useState(false); const [error, setError] = useState(() => searchParams.has('reject') ? 'Authentication failed, please login' : '' ); @@ -21,41 +23,86 @@ export default function Login() { }) .then((res) => res.json()) .then((res) => { - if (res.error) setError(res.error); - else router.push('/'); + if (res.error) { + setError(res.error); + } else router.push('/'); }); }; return ( - - PeerDB +
+ PeerDB +
+ ) => + setPass(e.target.value) + } + onKeyDown={(e: React.KeyboardEvent) => { + if (e.key === 'Enter') { + login(); + } + }} + /> + +
+ {error && (
{error}
)} - ) => - setPass(e.target.value) - } - onKeyPress={(e: React.KeyboardEvent) => { - if (e.key === 'Enter') { - login(); - } - }} - /> - - +
); } diff --git a/ui/app/mirrors/layout.tsx b/ui/app/mirrors/layout.tsx index 69a53b44ea..2cabddbcbb 100644 --- a/ui/app/mirrors/layout.tsx +++ b/ui/app/mirrors/layout.tsx @@ -1,7 +1,12 @@ import SidebarComponent from '@/components/SidebarComponent'; import { Layout } from '@/lib/Layout'; +import { cookies } from 'next/headers'; import { PropsWithChildren } from 'react'; export default function PageLayout({ children }: PropsWithChildren) { - return }>{children}; + return ( + }> + {children} + + ); } diff --git a/ui/app/peers/layout.tsx b/ui/app/peers/layout.tsx index 69a53b44ea..2cabddbcbb 100644 --- a/ui/app/peers/layout.tsx +++ b/ui/app/peers/layout.tsx @@ -1,7 +1,12 @@ import SidebarComponent from '@/components/SidebarComponent'; import { Layout } from '@/lib/Layout'; +import { cookies } from 'next/headers'; import { PropsWithChildren } from 'react'; export default function PageLayout({ children }: PropsWithChildren) { - return }>{children}; + return ( + }> + {children} + + ); } diff --git a/ui/components/Logout.tsx b/ui/components/Logout.tsx index 21c8e8267a..dc262245f5 100644 --- a/ui/components/Logout.tsx +++ b/ui/components/Logout.tsx @@ -4,13 +4,14 @@ import { Button } from '@/lib/Button'; export default function Logout() { return ( ); }