headplane/app/routes/auth/logout.ts

16 lines
420 B
TypeScript
Raw Normal View History

2024-12-08 13:27:51 -05:00
import { ActionFunctionArgs, redirect } from '@remix-run/node'
2024-03-30 02:44:06 -04:00
import { destroySession, getSession } from '~/utils/sessions'
2024-12-08 13:27:51 -05:00
export async function loader() {
return redirect('/machines')
}
2024-03-30 02:44:06 -04:00
export async function action({ request }: ActionFunctionArgs) {
const session = await getSession(request.headers.get('Cookie'))
2024-12-08 13:27:51 -05:00
return redirect('/login', {
2024-03-30 02:44:06 -04:00
headers: {
'Set-Cookie': await destroySession(session)
}
})
}