feat: refactor/reorganize auth routes

This commit is contained in:
Aarnav Tale 2024-12-08 13:27:51 -05:00
parent 9d64a5beac
commit 50e43bc0c3
No known key found for this signature in database
7 changed files with 102 additions and 66 deletions

15
app/routes/auth/logout.ts Normal file
View file

@ -0,0 +1,15 @@
import { ActionFunctionArgs, redirect } from '@remix-run/node'
import { destroySession, getSession } from '~/utils/sessions'
export async function loader() {
return redirect('/machines')
}
export async function action({ request }: ActionFunctionArgs) {
const session = await getSession(request.headers.get('Cookie'))
return redirect('/login', {
headers: {
'Set-Cookie': await destroySession(session)
}
})
}