From 6398e974988b005cc3d23ac37cb13859c6b3ca1c Mon Sep 17 00:00:00 2001 From: Robin Malley Date: Sun, 12 Sep 2021 01:47:40 +0000 Subject: [PATCH] Add a logout button Add a button that only shows when users are logged in, allowing them to log out. --- src/lua/endpoints/index_get.lua | 6 +++--- src/pages/author_index.etlua.in | 14 +++++++++++++- src/pages/index.etlua.in | 5 +++-- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/lua/endpoints/index_get.lua b/src/lua/endpoints/index_get.lua index e80b84d..3b13a41 100644 --- a/src/lua/endpoints/index_get.lua +++ b/src/lua/endpoints/index_get.lua @@ -43,7 +43,7 @@ local function get_site_home(req, loggedin) loggedin = loggedin } end -local function get_author_home(req) +local function get_author_home(req, loggedin) --print("Looking at author home...") local host = http_request_get_host(req) local subdomain = host:match("([^\\.]+)") @@ -120,11 +120,11 @@ local function index_get(req) --author home page local cachepath = string.format("%s.%s",subdomain,config.domain) text = cache.render(cachepath, function() - return get_author_home(req) + return get_author_home(req, author ~= nil) end) elseif host ~= config.domain and author == subdomain then --author's home page for the author, don't cache, display unlisted - text = get_author_home(req) + text = get_author_home(req, author ~= nil) end assert(text) http_response(req,200,text) diff --git a/src/pages/author_index.etlua.in b/src/pages/author_index.etlua.in index 34c4b4c..927402f 100644 --- a/src/pages/author_index.etlua.in +++ b/src/pages/author_index.etlua.in @@ -5,7 +5,19 @@ <%= author %>.<%= domain %>
- New paste +
+ New paste + <% if not loggedin then %> + Log in + <% else %> + Log out + <% end %> + + +
<%= bio %> diff --git a/src/pages/index.etlua.in b/src/pages/index.etlua.in index 371c7e3..dee9959 100644 --- a/src/pages/index.etlua.in +++ b/src/pages/index.etlua.in @@ -8,12 +8,13 @@
New paste - <% if loggedin then %> + <% if not loggedin then %> Log in + Register <% else %> Log out + <% end %> - Register