site profile: no csrf/flash unless signed in

This commit is contained in:
Kyle Drake 2025-04-26 17:34:34 -05:00
parent 380bd5f484
commit 369f1655a9
2 changed files with 69 additions and 65 deletions

View file

@ -19,45 +19,47 @@
<% end %> <% end %>
<% end %> <% end %>
<div class="modal hide" id="addTag" tabindex="-1" role="dialog" aria-labelledby="addTagLabel" aria-hidden="true"> <% if current_site && current_site == site %>
<form method="POST" action="/tags/add"> <div class="modal hide" id="addTag" tabindex="-1" role="dialog" aria-labelledby="addTagLabel" aria-hidden="true">
<input type="hidden" value="<%= csrf_token %>" name="csrf_token"> <form method="POST" action="/tags/add">
<div class="modal-header"> <input type="hidden" value="<%= csrf_token %>" name="csrf_token">
<button class="close" type="button" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i></button> <div class="modal-header">
<h3 id="addTagLabel">Add a Tag</h3> <button class="close" type="button" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i></button>
</div> <h3 id="addTagLabel">Add a Tag</h3>
<div class="modal-body"> </div>
<p> <div class="modal-body">
A tag can only be a single word, and can only contain letters and numbers. <p>
</p> A tag can only be a single word, and can only contain letters and numbers.
<input type="text" name="tags" class="typeahead"> </p>
</div> <input type="text" name="tags" class="typeahead">
<div class="modal-footer"> </div>
<button class="btn cancel" data-dismiss="modal" aria-hidden="true">Cancel</button> <div class="modal-footer">
<button type="submit" class="btn-Action">Add Tag</button> <button class="btn cancel" data-dismiss="modal" aria-hidden="true">Cancel</button>
</div> <button type="submit" class="btn-Action">Add Tag</button>
</form> </div>
</div> </form>
</div>
<div class="modal hide" id="removeTag" tabindex="-1" role="dialog" aria-labelledby="removeTagLabel" aria-hidden="true"> <div class="modal hide" id="removeTag" tabindex="-1" role="dialog" aria-labelledby="removeTagLabel" aria-hidden="true">
<form method="POST" action="/tags/remove"> <form method="POST" action="/tags/remove">
<input type="hidden" value="<%= csrf_token %>" name="csrf_token"> <input type="hidden" value="<%= csrf_token %>" name="csrf_token">
<div class="modal-header"> <div class="modal-header">
<button class="close" type="button" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i></button> <button class="close" type="button" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i></button>
<h3 id="removeTagLabel">Remove Tags</h3> <h3 id="removeTagLabel">Remove Tags</h3>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<p> <p>
Select the tags you would like to remove: Select the tags you would like to remove:
</p> </p>
<% site.tags.each do |tag| %> <% site.tags.each do |tag| %>
<input name="tags[]" type="checkbox" value="<%= tag.name %>"> <%= tag.name %> <input name="tags[]" type="checkbox" value="<%= tag.name %>"> <%= tag.name %>
<br> <br>
<% end %> <% end %>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button class="btn cancel" data-dismiss="modal" aria-hidden="true">Cancel</button> <button class="btn cancel" data-dismiss="modal" aria-hidden="true">Cancel</button>
<button type="submit" class="btn-Action">Remove Tag(s)</button> <button type="submit" class="btn-Action">Remove Tag(s)</button>
</div> </div>
</form> </form>
</div> </div>
<% end %>

View file

@ -1,5 +1,5 @@
<div class="header-Outro with-site-image"> <div class="header-Outro with-site-image">
<% if flash.keys.length > 0 %> <% if current_site && flash.keys.length > 0 %>
<div class="row content"> <div class="row content">
<div class="alert txt-Center"> <div class="alert txt-Center">
<% flash.keys.each do |key| %> <% flash.keys.each do |key| %>
@ -90,28 +90,30 @@
</div></div> </div></div>
</div> </div>
<div class="modal hide" id="block" tabindex="-1" role="dialog" aria-labelledby="blockLabel" aria-hidden="true"> <% if current_site %>
<form method="POST" action="/site/<%= site.username %>/block"> <div class="modal hide" id="block" tabindex="-1" role="dialog" aria-labelledby="blockLabel" aria-hidden="true">
<input type="hidden" value="<%= csrf_token %>" name="csrf_token"> <form method="POST" action="/site/<%= site.username %>/block">
<div class="modal-header"> <input type="hidden" value="<%= csrf_token %>" name="csrf_token">
<button class="close" type="button" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i></button> <div class="modal-header">
<h3 id="blockLabel">Block Site</h3> <button class="close" type="button" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i></button>
</div> <h3 id="blockLabel">Block Site</h3>
<div class="modal-body"> </div>
<p>You are going to block this site. This will do the following:</p> <div class="modal-body">
<p>You are going to block this site. This will do the following:</p>
<ul> <ul>
<li>You will no longer see this site in searches.</li> <li>You will no longer see this site in searches.</li>
<li>Site will no longer see your site in searches.</li> <li>Site will no longer see your site in searches.</li>
<li>Site will not be able to comment on your site profile.</li> <li>Site will not be able to comment on your site profile.</li>
<li>Any comments this site has posted to your profile will not be displayed.</li> <li>Any comments this site has posted to your profile will not be displayed.</li>
</ul> </ul>
<p>Are you sure you want to do this?</p> <p>Are you sure you want to do this?</p>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button class="btn cancel" data-dismiss="modal" aria-hidden="true">Cancel</button> <button class="btn cancel" data-dismiss="modal" aria-hidden="true">Cancel</button>
<button type="submit" class="btn-Action">Block Site</button> <button type="submit" class="btn-Action">Block Site</button>
</div> </div>
</form> </form>
</div> </div>
<% end %>