Skip to content

Commit

Permalink
fix(ui): ensure old behavior of not setting password works
Browse files Browse the repository at this point in the history
  • Loading branch information
iamKunalGupta committed Jan 8, 2024
1 parent c933260 commit 61671ab
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
22 changes: 13 additions & 9 deletions ui/components/Logout.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
'use client';
import { Button } from '@/lib/Button';
import { useRouter } from 'next/navigation';
import { useSession } from 'next-auth/react';

export default function Logout() {
const { data: session } = useSession();
const router = useRouter();
return (
<Button
style={{ backgroundColor: 'white', border: '1px solid rgba(0,0,0,0.15)' }}
onClick={() => router.push('/api/auth/signout')
}
>
Log out
</Button>
);
if (session) {
return (
<Button
style={{ backgroundColor: 'white', border: '1px solid rgba(0,0,0,0.15)' }}
onClick={() => router.push('/api/auth/signout')
}
>
Log out
</Button>
);
}
}
3 changes: 3 additions & 0 deletions ui/components/SidebarComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Sidebar, SidebarItem } from '@/lib/Sidebar';
import Link from 'next/link';
import useSWR from 'swr';
import { useLocalStorage } from 'usehooks-ts';
import { SessionProvider } from 'next-auth/react';

const centerFlexStyle = {
display: 'flex',
Expand All @@ -34,6 +35,7 @@ export default function SidebarComponent(props: { }) {
);

return (
<SessionProvider>
<Sidebar
topTitle={
<Label as={Link} href='/'>
Expand Down Expand Up @@ -107,5 +109,6 @@ export default function SidebarComponent(props: { }) {
Alert Configuration
</SidebarItem>
</Sidebar>
</SessionProvider>
);
}
5 changes: 4 additions & 1 deletion ui/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { NextRequest, NextResponse } from 'next/server';
import { withAuth } from 'next-auth/middleware';
import { Configuration } from '@/app/config/config';

const authMiddleware = withAuth({});


export default async function middleware(req: NextRequest, resp: NextResponse) {
return (authMiddleware as any)(req);
if (Configuration.authentication.PEERDB_PASSWORD) {
return (authMiddleware as any)(req);
}
}


Expand Down

0 comments on commit 61671ab

Please sign in to comment.