From ec72bd2a1e57705edf1eafd9ea1a8192dc93b180 Mon Sep 17 00:00:00 2001 From: Al Beano Date: Sun, 16 Jul 2017 21:22:13 +0100 Subject: [PATCH] Toolbar with logout button --- lib/cyberman.pm | 17 +++++++++++++++++ views/layouts/main.tt | 28 ++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/lib/cyberman.pm b/lib/cyberman.pm index b923d14..c638aeb 100644 --- a/lib/cyberman.pm +++ b/lib/cyberman.pm @@ -57,11 +57,20 @@ hook 'before' => sub { my $uid = cookieval("id"); my $token = cookieval("token"); my $auth = 0; + my $email; if ($uid && $token) { $auth = get_auth($uid, $token); + $email = database->quick_lookup( + "user", + { + "id" => $uid, + }, + "email", + ); } var auth => $auth; + var email => $email; }; get qr{^/(index)?$} => sub { @@ -183,4 +192,12 @@ post '/login' => sub { }; }; +post '/logout' => sub { + cookie 'id' => undef; + cookie 'token' => undef; + template 'redir' => { + "redir" => "index", + }; +}; + true; diff --git a/views/layouts/main.tt b/views/layouts/main.tt index e6beb8b..a36d1dd 100644 --- a/views/layouts/main.tt +++ b/views/layouts/main.tt @@ -26,6 +26,9 @@ p { margin-left: auto; margin-right: auto; } +.toolbar { + border: 1px solid white; +} a.bracketButton { text-decoration: none; @@ -33,6 +36,17 @@ a.bracketButton { a.bracketButton:hover { text-decoration: underline; } +button.textButton { + background: none !important; + color: inherit; + border: none; + padding: 0 !important; + font: inherit; + cursor: pointer; +} +button.textButton:hover { + text-decoration: underline; +} form.login>table>tbody>tr>td>label { margin-right: 10px; @@ -49,6 +63,20 @@ table.domains>tbody>tr>td:first-child>* { + <% IF vars.auth %> +
+
+ + Logged in as <% vars.email | html_entity %> + + +
+ [  ] +
+
+
+
+ <% END %> <% content %>