Skip to content

Commit

Permalink
Merge pull request #4880 from signalco-io/next
Browse files Browse the repository at this point in the history
Next
  • Loading branch information
AleksandarDev authored Mar 29, 2024
2 parents 4f1f3f7 + 3e570b6 commit 88be4a3
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 48 deletions.
32 changes: 32 additions & 0 deletions web/apps/workingparty/app/(rest)/(app)/app/logout/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
'use client';

import { useEffect } from 'react';
import { useRouter } from 'next/navigation';
import { useMutation } from '@tanstack/react-query';
import { Spinner } from '@signalco/ui-primitives/Spinner';
import { KnownPages } from '../../../../../src/knownPages';

function useLogOut() {
const router = useRouter();

return useMutation({
mutationFn: () => fetch('/api/auth/logout', { method: 'POST' }),
onSettled: () => {
router.push(KnownPages.Landing);
},
});
}

export default function AppLogoutPage() {
const logOut = useLogOut();

useEffect(() => {
logOut.mutate();
}, []);

return (
<div className="flex h-full items-center justify-center">
<Spinner loadingLabel={'Logging you out'} loading />
</div>
);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use client';

import { Typography } from '@signalco/ui-primitives/Typography';
import { Stack } from '@signalco/ui-primitives/Stack';
import { useSearchParam } from '@signalco/hooks/useSearchParam';

export function LoginEmailSentVerifyMessage() {
Expand All @@ -10,13 +12,18 @@ export function LoginEmailSentVerifyMessage() {
<>
<Typography center level="h2" semiBold>Email Login</Typography>
<Typography center level="body1" secondary>
Keep this window open, and in new tab or another device, open the link we just sent to{' '}
<span className="inline font-semibold text-blue-500">{email}</span>{' '}
with security code:
</Typography>
<Typography className="rounded border p-3 text-center font-bold">
{verifyPhrase}
Open the link we just sent to{' '}
<span className="inline font-semibold text-blue-500">{email}</span>,
{' '}verify it matches security code displayed below.
</Typography>
<Stack spacing={1}>
<Typography className="rounded border p-3 text-center font-bold">
{verifyPhrase}
</Typography>
<Typography center level="body2" tertiary>
You can close this window after you have successfully logged in.
</Typography>
</Stack>
</>
);
}
6 changes: 6 additions & 0 deletions web/apps/workingparty/app/api/auth/logout/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { cookies } from 'next/headers';

export async function POST() {
cookies().delete('wp_session');
return Response.json(null);
}
2 changes: 1 addition & 1 deletion web/apps/workingparty/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"@vercel/analytics": "1.2.2",
"classix": "2.1.36",
"jose": "5.2.3",
"next": "14.2.0-canary.47",
"next": "14.2.0-canary.48",
"next-secure-headers": "2.2.0",
"next-themes": "0.3.0",
"nanoid": "5.0.6",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ export function AppSidebarProfileButton() {
Settings
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem className="text-red-600 dark:text-red-400" startDecorator={<LogOut className="w-5" />}>Logout</DropdownMenuItem>
<DropdownMenuItem
className="text-red-600 dark:text-red-400"
startDecorator={<LogOut className="w-5" />}
href={KnownPages.AppLogout}>
Logout
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
);
Expand Down
80 changes: 40 additions & 40 deletions web/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 88be4a3

Please sign in to comment.