forked from .cyb/cyberman
Toolbar with logout button
This commit is contained in:
parent
2afe5b1918
commit
ec72bd2a1e
|
@ -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;
|
||||
|
|
|
@ -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>* {
|
|||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<% IF vars.auth %>
|
||||
<div class="toolbar">
|
||||
<div class="body">
|
||||
<span>
|
||||
Logged in as <% vars.email | html_entity %>
|
||||
</span>
|
||||
<span style="float:right;">
|
||||
<form action="/logout" method="POST">
|
||||
[ <button class="textButton" action="submit">log out</button> ]
|
||||
</form>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<% END %>
|
||||
<% content %>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in New Issue