feat: refactor/reorganize auth routes
This commit is contained in:
parent
9d64a5beac
commit
50e43bc0c3
7 changed files with 102 additions and 66 deletions
15
app/routes/auth/logout.ts
Normal file
15
app/routes/auth/logout.ts
Normal 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)
|
||||
}
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue