Display vote name even when unauthenticated

For example, when sharing the link in messaging apps.
This commit is contained in:
ricola 2026-01-09 16:25:10 -06:00
parent 33bc3e1446
commit 45c8e9b6b4
3 changed files with 33 additions and 11 deletions

View file

@ -317,10 +317,12 @@ post '/votes/new' do
end
get '/votes/:id' do
require_login
find_vote
if not @vote
erb :votes_show_unknown
else
if not current_user
erb :votes_show_unauthenticated
else
case @vote.state
when 'draft'
@ -335,6 +337,7 @@ get '/votes/:id' do
erb :votes_show_closed
end
end
end
end
get '/votes/:id/edit' do

View file

@ -46,6 +46,8 @@
<div class="d-flex flex-wrap justify-content-end pe-3 py-3 mb-4">
<% if current_user %>
<%= current_user.email %>
<% else %>
&nbsp;
<% end %>
</div>

View file

@ -0,0 +1,17 @@
<div class="mb-5">
<h1><%= @vote.title %></h1>
</div>
<p class="alert alert-warning mb-4"><%= _("You need to log in to see the details of this vote.") %></p>
<form action="/login" method="post" class="mb-5">
<div class="mb-3">
<label for="email" class="form-label"><%= _("Email") %></label>
<input type="text" name="email" class="form-control">
</div>
<div class="mb-3">
<label for="password" class="form-label"><%= _("Password") %></label>
<input type="password" name="password" class="form-control">
</div>
<button type="submit" class="btn btn-primary"><%= _("Login") %></button>
</form>