feat: refactoring, soem work on forms
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
import { define } from "../../utils.ts";
|
||||
|
||||
export default define.middleware((ctx) => {
|
||||
if (!ctx.state.loggedIn) {
|
||||
return ctx.redirect("/sign-in", 303);
|
||||
}
|
||||
|
||||
return ctx.next();
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
import Headline from "../../components/Headline.tsx";
|
||||
import { define } from "../../utils.ts";
|
||||
|
||||
export default define.page(function Dashboard() {
|
||||
return (
|
||||
<div class="container mx-auto p-4">
|
||||
<Headline>Dashboard</Headline>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,15 @@
|
||||
import { unsetAuthCookie } from "../../lib/auth.ts";
|
||||
import { define } from "../../utils.ts";
|
||||
|
||||
export const handler = define.handlers({
|
||||
POST(ctx) {
|
||||
const headers = new Headers();
|
||||
unsetAuthCookie(headers);
|
||||
|
||||
headers.set("location", new URL("/", ctx.req.url).toString());
|
||||
return new Response(null, {
|
||||
status: 303,
|
||||
headers,
|
||||
});
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user