fully functional. UX/UI stage
This commit is contained in:
18
smartsoltech/static/assets/js/get-csrf-token.js
Normal file
18
smartsoltech/static/assets/js/get-csrf-token.js
Normal file
@@ -0,0 +1,18 @@
|
||||
// Функция для получения CSRF токена из куков
|
||||
function getCookie(name) {
|
||||
let cookieValue = null;
|
||||
if (document.cookie && document.cookie !== '') {
|
||||
const cookies = document.cookie.split(';');
|
||||
for (let i = 0; i < cookies.length; i++) {
|
||||
const cookie = cookies[i].trim();
|
||||
if (cookie.substring(0, name.length + 1) === (name + '=')) {
|
||||
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return cookieValue;
|
||||
}
|
||||
|
||||
// Инициализация переменной csrftoken, которая будет доступна глобально
|
||||
const csrftoken = getCookie('csrftoken');
|
||||
Reference in New Issue
Block a user