turbo_form 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/turbo_form.js +8 -1
- data/lib/turbo_form/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4cb1af8f341d1112a85f86bc4fe28470e83f867994be6029a32fbd996da03677
|
|
4
|
+
data.tar.gz: 97afa78d913454ea096c0f988ecb85d99f7ebe7027f02f2e19cc40af534b624e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 221fbbcd5e31c6191a208cefb92089f70094ef5709547cdb63984a4bb419342d7109dfe4001135853ee7380537b63d82a8cb2fef64af550d40a1a713dfa93f20
|
|
7
|
+
data.tar.gz: 2e7cd4ecec1194cc7605035e9a51c9dcd1542f3c45410c6497a74221e8ae6a037991650a6d928bdf230097af4cfbc0e7aaf73751326a912f291649b9e22221b4
|
|
@@ -26,7 +26,7 @@ class FormRefresh {
|
|
|
26
26
|
async start() {
|
|
27
27
|
this.requestStarted()
|
|
28
28
|
try {
|
|
29
|
-
const response = await Turbo.fetch(this.location, { method: "PATCH", body: new FormData(this.formElement), headers: this.target.headers })
|
|
29
|
+
const response = await Turbo.fetch(this.location, { method: "PATCH", body: new FormData(this.formElement), headers: { ...this.target.headers, "X-CSRF-Token": csrfToken() } })
|
|
30
30
|
|
|
31
31
|
this.target.render(response.status, await response.text())
|
|
32
32
|
} finally {
|
|
@@ -88,6 +88,13 @@ function targetFor(form) {
|
|
|
88
88
|
return frame ? new FrameTarget(frame) : new PageTarget()
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
// The form's own authenticity token is scoped to its action and method when
|
|
92
|
+
// per-form tokens are on, as they are by default, so it can't vouch for this
|
|
93
|
+
// PATCH. The page's token can, as it does for Turbo's own submissions.
|
|
94
|
+
function csrfToken() {
|
|
95
|
+
return document.querySelector('meta[name="csrf-token"]')?.content
|
|
96
|
+
}
|
|
97
|
+
|
|
91
98
|
const triggerSelector = "[data-turbo-form-trigger]"
|
|
92
99
|
|
|
93
100
|
// Shaped like Turbo's observers. One listener per event the page's triggers
|
data/lib/turbo_form/version.rb
CHANGED