From 1d4237d687ae1b8aca3886fb80f08f73a6cac5c3 Mon Sep 17 00:00:00 2001 From: Alex Ling Date: Fri, 3 Apr 2020 23:31:24 +0000 Subject: [PATCH] Pass in admin information when rendering all pages --- src/util.cr | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/util.cr b/src/util.cr index ca7b08d..8fb67c9 100644 --- a/src/util.cr +++ b/src/util.cr @@ -3,7 +3,17 @@ require "big" IMGS_PER_PAGE = 5 macro layout(name) - render "src/views/#{{{name}}}.ecr", "src/views/layout.ecr" + begin + cookie = env.request.cookies.find { |c| c.name == "token" } + is_admin = false + unless cookie.nil? + is_admin = @context.storage.verify_admin cookie.value + end + render "src/views/#{{{name}}}.ecr", "src/views/layout.ecr" + rescue e + message = e.to_s + render "message" + end end macro send_img(env, img)