Files
desk-moloni/modules/desk_moloni/views/admin/partials/csrf_token.php
Emanuel Almeida 8c4f68576f chore: add spec-kit and standardize signatures
- Added GitHub spec-kit for development workflow
- Standardized file signatures to Descomplicar® format
- Updated development configuration

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-12 01:27:37 +01:00

56 lines
1.6 KiB
PHP

/**
* Descomplicar® Crescimento Digital
* https://descomplicar.pt
*/
<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>
<?php
/**
* CSRF Protection Token Include
*
* Include this file in all forms that need CSRF protection
* Usage: <?php include(module_views_path('desk_moloni', 'admin/partials/csrf_token')); ?>
*
* @package DeskMoloni\Views\Partials
* @version 3.0
*/
// Get CSRF token name and hash
$csrf_token_name = $this->security->get_csrf_token_name();
$csrf_hash = $this->security->get_csrf_hash();
?>
<!-- CSRF Protection Token -->
<input type="hidden" name="<?php echo $csrf_token_name; ?>" value="<?php echo $csrf_hash; ?>" id="csrf_token">
<script>
// Auto-refresh CSRF token for AJAX requests
if (typeof window.deskMoloniCSRF === 'undefined') {
window.deskMoloniCSRF = {
token_name: '<?php echo $csrf_token_name; ?>',
token_value: '<?php echo $csrf_hash; ?>',
// Get current token for AJAX requests
getToken: function() {
return {
name: this.token_name,
value: this.token_value
};
},
// Update token value (called after successful AJAX requests)
updateToken: function(newValue) {
this.token_value = newValue;
document.getElementById('csrf_token').value = newValue;
},
// Add CSRF token to AJAX data
addToData: function(data) {
if (typeof data === 'object') {
data[this.token_name] = this.token_value;
}
return data;
}
};
}
</script>