Add tokens list

This commit is contained in:
Citlali del Rey 2022-11-05 10:09:02 -07:00
parent 9ecfff7557
commit 1a3096669b
Signed by: nullobsi
GPG Key ID: 933A1F44222C2634
3 changed files with 38 additions and 0 deletions

View File

@ -74,6 +74,7 @@ sub startup($self) {
$r->get('/login')->to('Login#login');
$r->post('/auth')->to('Login#auth');
$r->get('/my')->to('Interface#landing');
$r->get('/my/tokens')->to('Interface#token_list');
}
1;

View File

@ -41,4 +41,16 @@ sub landing($c) {
})
}
sub token_list($c) {
my $uid = $c->session->{uid};
if (!defined $uid) {
return $c->redirect_to("/login");
}
return $c->users->list_tokens($uid)->then(sub ($tokens) {
$c->stash(tokens => $tokens);
$c->render('interface/tokens');
})
}
1;

View File

@ -0,0 +1,25 @@
% layout "default";
% title "Uploads";
<h1>Tokens</h1>
<p>Here you can delete or generate tokens.</p>
<table>
<tr>
<th>Token ID</th>
<th>App Name</th>
<th>Actions</th>
</tr>
% for my $token (@$tokens) {
<tr>
<td><%= $token->{id} %></td>
<td><%= $token->{app_name} %></td>
<td>
<a href="/my/tokens/<%= $token->{id} %>/delete">Delete</a>
</td>
</tr>
% }
</table>
<a href="/my/tokens/generate">
Generate Token
</a>