diff options
Diffstat (limited to 'templates')
| -rw-r--r-- | templates/account_password.html | 1 | ||||
| -rw-r--r-- | templates/admin.html | 1 | ||||
| -rw-r--r-- | templates/js/admin.js | 3 | ||||
| -rw-r--r-- | templates/login.html | 1 | ||||
| -rw-r--r-- | templates/php/account_password.php | 1 | ||||
| -rw-r--r-- | templates/php/login.php | 1 | ||||
| -rw-r--r-- | templates/php/register.php | 1 | ||||
| -rw-r--r-- | templates/register.html | 1 |
8 files changed, 10 insertions, 0 deletions
diff --git a/templates/account_password.html b/templates/account_password.html index ba40761..68fb95f 100644 --- a/templates/account_password.html +++ b/templates/account_password.html @@ -11,6 +11,7 @@ <div class="container content-container"> <h2>Change Password</h2> <form id="change-password-form" action="{{.Paths.AccountPassword}}" method="post"> + <input type="hidden" name="gorilla.csrf.Token" value="{{.CSRFToken}}"> <div class="form-group"> <label for="current_password">Current Password</label> <input type="password" id="current_password" name="current_password" required> diff --git a/templates/admin.html b/templates/admin.html index ac4ba94..c2f9488 100644 --- a/templates/admin.html +++ b/templates/admin.html @@ -3,6 +3,7 @@ <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <meta name="csrf-token" content="{{.CSRFToken}}"> <title>Admin Dashboard</title> <link rel="stylesheet" href="{{.Paths.Assets}}/css/style.css"> <link rel="stylesheet" href="{{.Paths.Assets}}/css/admin.css"> diff --git a/templates/js/admin.js b/templates/js/admin.js index 4dff572..0b26e2f 100644 --- a/templates/js/admin.js +++ b/templates/js/admin.js @@ -7,8 +7,11 @@ * @returns {Promise<Response>} */ async function fetchApi(url, options = {}) { + const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content'); + options.headers = { ...options.headers, + 'X-CSRF-Token': csrfToken }; // Set content type for methods that have a body. diff --git a/templates/login.html b/templates/login.html index 12f27eb..b2f847c 100644 --- a/templates/login.html +++ b/templates/login.html @@ -10,6 +10,7 @@ <div class="container form-container"> <h2>Login Required</h2> <form id="login-form" action="{{.Paths.Login}}" method="post"> + <input type="hidden" name="gorilla.csrf.Token" value="{{.CSRFToken}}"> <div class="form-group"> <label for="username">Username</label> <input type="text" id="username" name="username" required> diff --git a/templates/php/account_password.php b/templates/php/account_password.php index b287c90..8a1871d 100644 --- a/templates/php/account_password.php +++ b/templates/php/account_password.php @@ -18,6 +18,7 @@ <div class="container content-container"> <h2>Change Password</h2> <form id="change-password-form" action="<?php echo htmlspecialchars($paths['AccountPassword']); ?>" method="post"> + <input type="hidden" name="gorilla.csrf.Token" value="<?php echo htmlspecialchars($_SERVER['HTTP_X_CSRF_TOKEN']); ?>"> <div class="form-group"> <label for="current_password">Current Password</label> <input type="password" id="current_password" name="current_password" required> diff --git a/templates/php/login.php b/templates/php/login.php index f3e5113..c4644ef 100644 --- a/templates/php/login.php +++ b/templates/php/login.php @@ -17,6 +17,7 @@ <div class="container form-container"> <h2>Login Required</h2> <form id="login-form" action="<?php echo htmlspecialchars($paths['Login']); ?>" method="post"> + <input type="hidden" name="gorilla.csrf.Token" value="<?php echo htmlspecialchars($_SERVER['HTTP_X_CSRF_TOKEN']); ?>"> <div class="form-group"> <label for="username">Username</label> <input type="text" id="username" name="username" required> diff --git a/templates/php/register.php b/templates/php/register.php index 956467a..31edf25 100644 --- a/templates/php/register.php +++ b/templates/php/register.php @@ -17,6 +17,7 @@ <div class="container form-container"> <h2>Create Account</h2> <form id="register-form" action="<?php echo htmlspecialchars($paths['Register']); ?>" method="post"> + <input type="hidden" name="gorilla.csrf.Token" value="<?php echo htmlspecialchars($_SERVER['HTTP_X_CSRF_TOKEN']); ?>"> <div class="form-group"> <label for="username">Username</label> <input type="text" id="username" name="username" required> diff --git a/templates/register.html b/templates/register.html index d98ef4d..7db7972 100644 --- a/templates/register.html +++ b/templates/register.html @@ -10,6 +10,7 @@ <div class="container form-container"> <h2>Create Account</h2> <form id="register-form" action="{{.Paths.Register}}" method="post"> + <input type="hidden" name="gorilla.csrf.Token" value="{{.CSRFToken}}"> <div class="form-group"> <label for="username">Username</label> <input type="text" id="username" name="username" required> |
