Skip to content

Commit

Permalink
Add button to view secret as author
Browse files Browse the repository at this point in the history
Previously, the secret template doesn't allow the author to view
the secret they just created.  Looking at web server logs, there
are a fair number of users who create a secret but never decrypt
it.  From a UX perspective, I suspect not being able to test
viewing their own secret leads them to believe the application
doesn't work; then they don't come back to use the service again.

To view your secret as the author, you either have to clear the
cookie for the site, or view the secret link in a different browser
that doesn't contain the cookie (this was by design).

To allow users to test their own secret, this commit adds a view
button to the secret view.  When the button is clicked, the secret
id is removed from the cookie and the user redirected to view the
secret as they would have been if they weren't the author.
  • Loading branch information
renderorange committed Mar 16, 2022
1 parent 642f5a4 commit 094182c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/Pasteburn/Controller/Secret.pm
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,14 @@ post q{/secret/:id} => sub {
redirect '/secret';
}

if ( $run_mode && $run_mode eq 'view' ) {
my $session_secrets = session->read('secrets');
delete $session_secrets->{ $secret_obj->id };
session->write( 'secrets', $session_secrets );

redirect '/secret/' . $secret_obj->id;
}

if ( $run_mode && $run_mode eq 'del' ) {
my $session_secrets = session->read('secrets');
delete $session_secrets->{ $secret_obj->id };
Expand Down
8 changes: 8 additions & 0 deletions public/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ div#actions a.button.half-width {
margin-right: 0.25rem;
}

div#actions input#view {
width: 99%;
}

div#actions form#view_form {
display: hidden;
}

div#actions input#delete {
width: 99%;
border-color: rgba(158,28,35,.2);
Expand Down
4 changes: 4 additions & 0 deletions views/secret.tt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
<div id="actions">
<a id="secret_link" class="button half-width" data-clipboard-text="/secret/[% id %]">Secret Link</a>
<a class="button half-width" href="/secret">Create New</a>
<form action="/secret/[% id %]" method="post" id="view_form">
<input name="rm" type="hidden" form="view_form" value="view">
</form>
<input class="button u-cf" id="view" type="submit" form="view_form" value="View Secret">
<form action="/secret/[% id %]" method="post" id="delete_form">
<input name="rm" type="hidden" form="delete_form" value="del">
</form>
Expand Down

0 comments on commit 094182c

Please sign in to comment.