feat: add logout and dropdown

This commit is contained in:
Aarnav Tale 2024-03-30 02:44:06 -04:00
parent 3f65c7e610
commit 50bcfa9c04
No known key found for this signature in database
7 changed files with 144 additions and 19 deletions

15
app/routes/logout.tsx Normal file
View file

@ -0,0 +1,15 @@
import { type ActionFunctionArgs, redirect } from '@remix-run/node'
import { destroySession, getSession } from '~/utils/sessions'
export async function action({ request }: ActionFunctionArgs) {
const session = await getSession(request.headers.get('Cookie'))
const returnTo = new URL(request.url).pathname
return redirect(`/login?returnTo=${returnTo}`, {
headers: {
// eslint-disable-next-line @typescript-eslint/naming-convention
'Set-Cookie': await destroySession(session)
}
})
}