diff --git a/app/templates/board.html b/app/templates/board.html index cc7fc93..52d2246 100644 --- a/app/templates/board.html +++ b/app/templates/board.html @@ -244,7 +244,11 @@ title: '', status: 'todo', create() { if (!this.title.trim()) return; - fetch(`/api/issues/${owner}/${repo}?title=${encodeURIComponent(this.title)}&labels=${this.status}`, { method: 'POST' }) + const csrf = document.cookie.match(/csrf_token=([^;]+)/); + fetch(`/api/issues/${owner}/${repo}?title=${encodeURIComponent(this.title)}&labels=${this.status}`, { + method: 'POST', + headers: { 'X-CSRF-Token': csrf ? csrf[1] : '' } + }) .then(r => r.json()) .then(data => { this.title = ''; @@ -277,7 +281,11 @@ onEnd: function(evt) { const cardId = evt.item.dataset.cardId; const toStatus = evt.to.dataset.status; - fetch(`/api/move?owner=${owner}&repo=${repo}&issue_id=${cardId}&column=${toStatus}`, { method: 'POST' }) + const csrf = document.cookie.match(/csrf_token=([^;]+)/); + fetch(`/api/move?owner=${owner}&repo=${repo}&issue_id=${cardId}&column=${toStatus}`, { + method: 'POST', + headers: { 'X-CSRF-Token': csrf ? csrf[1] : '' } + }) .then(() => { // ponytail: refresh current view after move const activeTab = document.querySelector('.view-tab.active'); diff --git a/app/templates/card_detail.html b/app/templates/card_detail.html index 03293ec..7b237a9 100644 --- a/app/templates/card_detail.html +++ b/app/templates/card_detail.html @@ -99,6 +99,12 @@