Fix logout race condition (#3578)

This commit is contained in:
jekkos
2022-10-16 23:15:22 +02:00
committed by jekkos
parent 3c32944ce9
commit b44993f2fa
4 changed files with 19 additions and 4 deletions

View File

@@ -5,7 +5,7 @@ function validate_method()
$url = $_SERVER['REQUEST_URI'];
$post_required = preg_match('/\/(save|delete*|remove*)\/?\d*?/', $url);
$post_required = preg_match('/\/(logout|save|delete*|remove*)\/?\d*?/', $url);
if($post_required && $_SERVER["REQUEST_METHOD"] != "POST" && empty($_POST))
{

View File

@@ -110,7 +110,7 @@
<div class="navbar-right" style="margin:0">
<?php echo anchor('home/change_password/'.$user_info->person_id, $user_info->first_name . ' ' . $user_info->last_name, array('class' => 'modal-dlg', 'data-btn-submit' => $this->lang->line('common_submit'), 'title' => $this->lang->line('employees_change_password'))); ?>
<?php echo ' | ' . ($this->input->get('debug') == 'true' ? $this->session->userdata('session_sha1') . ' | ' : ''); ?>
<a href="#" onclick="$.post('<?php echo site_url('home/logout'); ?>');"><?php echo $this->lang->line('login_logout');?></a>
<a href="javascript:void(0);" id="logout"><?php echo $this->lang->line('login_logout');?></a>
</div>
<div class="navbar-center" style="text-align:center">

View File

@@ -47,8 +47,23 @@
return ajax.apply(this, arguments);
};
$(document).ajaxComplete(setup_csrf_token);
$(document).ready(function(){
$("#logout").click(function(event) {
event.preventDefault();
$.ajax({
url: "<?php echo site_url('home/logout'); ?>",
data: {
"<?php echo $this->security->get_csrf_token_name(); ?>": csrf_token()
},
success: function() {
window.location.href = '<?php echo site_url(); ?>';
},
method: "POST"
});
});
});
var submit = $.fn.submit;

View File

@@ -1,4 +1,4 @@
version: '3.4'
version: '3.7'
volumes:
uploads: