From f02c4054984fb8c12bfa4af9560a5b2be38810c0 Mon Sep 17 00:00:00 2001 From: LarsVomMars Date: Thu, 30 Jul 2020 20:16:54 +0200 Subject: Added views and server setup --- src/handler/admin.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/handler/admin.ts (limited to 'src/handler') diff --git a/src/handler/admin.ts b/src/handler/admin.ts new file mode 100644 index 0000000..a626e50 --- /dev/null +++ b/src/handler/admin.ts @@ -0,0 +1,12 @@ +import type { HandlerFunc, Context } from "https://deno.land/x/abc@master/mod.ts"; +import * as log from "https://deno.land/std/log/mod.ts"; +import { isAdmin } from "../util/user.ts"; +import { isSetup } from "../util/server.ts"; + +export const render: HandlerFunc = async (c: Context) => { + if (await isAdmin(c)) + return await c.render("./src/views/admin.ejs", { initial: false }); + else if (!(await isSetup())) + return await c.render("./src/views/admin.ejs", { initial: true }); + return c.redirect("/"); +} -- cgit v1.2.3