fix for CSRF token in cached index

This commit is contained in:
Kyle Drake 2024-08-19 10:16:09 -05:00
parent 72d148b237
commit 601f58e025
3 changed files with 6 additions and 5 deletions

View file

@ -48,11 +48,12 @@ get '/?' do
@create_disabled = false
@index_rendered = SimpleCache.store :index, erb(:index, layout: :index_layout), (ENV['RACK_ENV'] == 'test' ? -1 : 1.hour)
return @index_rendered
else
return SimpleCache.get(:index)
@index_rendered = SimpleCache.get(:index)
end
@index_rendered.gsub! 'CSRF_TOKEN_HERE', csrf_token
@index_rendered
end
get '/welcome' do

View file

@ -30,7 +30,7 @@
})
$('input[type=text],input[type=password],input[type=email]').on('change focusout', function(obj) {
$.post('/create_validate', {field: obj.target.name, value: obj.target.value, is_education: $('input[name=is_education]')[0].value, csrf_token: '<%= csrf_token %>'}, function(res) {
$.post('/create_validate', {field: obj.target.name, value: obj.target.value, is_education: $('input[name=is_education]')[0].value, csrf_token: 'CSRF_TOKEN_HERE'}, function(res) {
if(res.result == 'ok') {
return $(obj.target).tooltip('hide')
}

View file

@ -91,7 +91,7 @@
</div>
<% else %>
<form id="createSiteForm" class="signup-Form" onsubmit="return false">
<input type="hidden" name="csrf_token" value="<%= csrf_token %>">
<input type="hidden" name="csrf_token" value="CSRF_TOKEN_HERE">
<input type="hidden" name="is_education" value="false">
<fieldset class="content">
<h2 class="gamma">Sign up for free</h2>