feat: add logout and dropdown
This commit is contained in:
parent
3f65c7e610
commit
50bcfa9c04
7 changed files with 144 additions and 19 deletions
15
app/routes/logout.tsx
Normal file
15
app/routes/logout.tsx
Normal 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)
|
||||
}
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue