action_auth 0.2.13 → 0.2.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b8591f70a89c2588e9f2194c268f963429b216632b6275a0367eb2b6685fe9af
4
- data.tar.gz: c2f9ba4b385f3fe7031316ed4f9dd2a937829116e4ae00ae0b0cf0dcde6b667a
3
+ metadata.gz: 0e857cd3b20f2efab695368d0b8b127a63cfe1639ef44dc4d346399c8aa446f7
4
+ data.tar.gz: 791837aee1c820e999896082cbdec807b65a0df7db1d29de02b31774682c5448
5
5
  SHA512:
6
- metadata.gz: a2b6717061e776eaa069b1cd46a06083454049030f94ac0c2b171f1e6b46afdf194ea64ce6849087ca3171d6470c784b8e53bf450edef5ef275f2d2610396c0f
7
- data.tar.gz: 38abb036b1cf021e90acb62909fa92b8fbcada9a5232c16c36876c15902004e2b3c10e02c9cb1489587d2aee2bb47fc78ad99ef60b88af95aefeab2edcf829ef
6
+ metadata.gz: f881d2e71ec6d1f2f1a5ccc764a9eecb333671163cba5ae8958e4a0b36c408f9670d05e818ce4ff1ab244583f2738f4376f9e8e987cc418748c8fce3217ee4ce
7
+ data.tar.gz: 30773441bd4c9184638cedba7ee4bb8a635f72a761bf6cc6abee5da65c26a4bdbe3cbd4aa72d7774a514276db539818e1b9f89b860c5a790b6a6785a898297d0
@@ -76,24 +76,40 @@ Stimulus.register(
76
76
  }
77
77
  );
78
78
 
79
- document.addEventListener('DOMContentLoaded', function () {
80
- const form = document.getElementById('webauthn_credential_form');
81
- if (form) {
82
- form.addEventListener('submit', function (event) {
83
- event.preventDefault();
84
- const formData = new FormData(form);
85
- fetch(form.action, {
86
- method: 'POST',
87
- body: formData,
88
- headers: {
89
- 'X-CSRF-Token': document.querySelector('[name="csrf-token"]').content
90
- },
91
- credentials: 'same-origin'
92
- }).then(response => {
93
- return response.json();
94
- }).then(data => {
95
- form.dispatchEvent(new CustomEvent('ajax:success', { detail: data }));
79
+ function submitFormWithTurbo(form) {
80
+ const formData = new FormData(form);
81
+ fetch(form.action, {
82
+ method: 'POST',
83
+ body: formData,
84
+ headers: {
85
+ 'X-CSRF-Token': document.querySelector('[name="csrf-token"]').content
86
+ },
87
+ credentials: 'same-origin'
88
+ }).then(response => {
89
+ return response.json();
90
+ }).then(data => {
91
+ form.dispatchEvent(new CustomEvent('ajax:success', { detail: data }));
92
+ });
93
+ }
94
+
95
+ if (!window.Turbo) {
96
+ document.addEventListener('DOMContentLoaded', function () {
97
+ const form = document.getElementById('webauthn_credential_form');
98
+ if (form) {
99
+ form.addEventListener('submit', function (event) {
100
+ event.preventDefault();
101
+ submitFormWithTurbo(form);
96
102
  });
97
- });
98
- }
99
- });
103
+ }
104
+ });
105
+ } else {
106
+ document.addEventListener('turbo:load', function () {
107
+ const form = document.getElementById('webauthn_credential_form');
108
+ if (form) {
109
+ form.addEventListener('submit', function (event) {
110
+ event.preventDefault();
111
+ submitFormWithTurbo(form);
112
+ });
113
+ }
114
+ });
115
+ }
@@ -22,7 +22,9 @@ class ActionAuth::WebauthnCredentialsController < ApplicationController
22
22
 
23
23
  respond_to do |format|
24
24
  format.json { render json: create_options }
25
- format.turbo_stream { render json: create_options }
25
+ if defined?(Turbo)
26
+ format.turbo_stream { render json: create_options }
27
+ end
26
28
  end
27
29
  end
28
30
 
@@ -1,3 +1,3 @@
1
1
  module ActionAuth
2
- VERSION = "0.2.13"
2
+ VERSION = "0.2.15"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.13
4
+ version: 0.2.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Kimura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-31 00:00:00.000000000 Z
11
+ date: 2024-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails