castle_devise 0.2.0 → 0.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7cc0ef1100f1ceb942fa1be6553b6b7ca862656e3c7a6b9b57459285a69a46a7
4
- data.tar.gz: 9222268f8c6e22fb367bbc0cc9a0ce52b5dc8854f8eefa0f2f34e2afaa4a92eb
3
+ metadata.gz: e2e9fa31620b96fd293ede84541d8073f264f227f84422339fa8d100c1e89ddc
4
+ data.tar.gz: 8dcbfacef3a3050bceb218d571d34a12e447b10c0b54acc93b559224aebf5f5f
5
5
  SHA512:
6
- metadata.gz: b6a11b460114c2133776991e4cde4f11a9030e5b019ea0162712b070a72b9adbd50cfad1f866cf90a92b05f505464ded6d9727a474c22edd5f65a9ed6f4fb0d6
7
- data.tar.gz: 292fe6b7dff6f11135c8e63b53ee4484cc8c1dd93dab449d58ef765b29935a8f4bbb925896bf4b4d06b21f1e44cc7ce748af8226287c832b9e8409026bc81c23
6
+ metadata.gz: b4bb3619aac0e96a1d2e00dbad37371b2c13855cb646b47819f80c333151e8072316ba7381587ed5b43867e6aa1841c4798cda18b7605bf4e382fad49cddf005
7
+ data.tar.gz: 8026202271990edbaeb18451bf25d5661c40c573728b781cf5a2268ab7e8900aa799be9da333f0beef44e3e65de8f6fb95ce49083314a68a665cbb1761543659
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## [Unreleased][main]
4
4
 
5
+ ## [0.3.0] - 2021-08-30
6
+
7
+ - Switch c.js to 2.0 version, Update c.js related helpers
8
+
5
9
  ## [0.2.0] - 2021-08-12
6
10
 
7
11
  - Add Log action for $profile_update event with $succeeded and $failed statuses during reset password process
@@ -13,6 +17,7 @@
13
17
 
14
18
  - Initial release
15
19
 
16
- [main]: https://github.com/castle/castle_devise/compare/v0.2.0...HEAD
20
+ [main]: https://github.com/castle/castle_devise/compare/v0.3.0...HEAD
21
+ [0.3.0]: https://github.com/castle/castle_devise/compare/v0.2.0...v0.3.0
17
22
  [0.2.0]: https://github.com/castle/castle_devise/compare/v0.1.0...v0.2.0
18
23
  [0.1.0]: https://github.com/castle/castle_devise/releases/tag/v0.1.0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- castle_devise (0.2.0)
4
+ castle_devise (0.3.0)
5
5
  activesupport (>= 5.0)
6
6
  castle-rb (>= 7.0, < 8.0)
7
7
  devise (>= 4.3.0, < 5.0)
@@ -171,6 +171,7 @@ GEM
171
171
  PLATFORMS
172
172
  x86_64-darwin-18
173
173
  x86_64-darwin-19
174
+ x86_64-darwin-20
174
175
 
175
176
  DEPENDENCIES
176
177
  actionmailer
data/README.md CHANGED
@@ -75,9 +75,7 @@ Include Castle's c.js script in the head section of your layout:
75
75
  Add the following tag to the the `<form>` tag in both `devise/registrations/new.html.erb` and `devise/sessions/new.html.erb` (if you haven't generated them yet, run `rails generate devise:views`):
76
76
 
77
77
  ```ruby
78
- <%= form_for @user do |f| %>
79
-
80
- <%= castle_request_token %>
78
+ <%= form_for @user, html: { onsubmit: castle_on_form_submit } do |f| %>
81
79
 
82
80
  <% end %>
83
81
  ```
@@ -87,20 +85,21 @@ You're set! Now verify that everything works by logging in to your application a
87
85
 
88
86
  #### Further steps if you're using Webpacker
89
87
 
90
- Add `castle.js` to your package.json file:
88
+ Add `@castleio/castle-js` to your package.json file:
91
89
 
92
90
  ```
93
- yarn add castle.js
91
+ yarn add @castleio/castle-js
94
92
  ```
95
93
 
96
- Require castle.js in your application pack:
94
+ configure castle in your application pack:
97
95
 
98
96
  ```javascript
99
- require("castle.js");
97
+ import * as Castle from '@castleio/castle-js'
100
98
 
101
- _castle("setAppId", YOUR_APPLICATION_ID);
99
+ Castle.configure(YOUR_APPLICATION_ID);
102
100
  ```
103
101
 
102
+ for advanced configuration follow [the readme](https://www.npmjs.com/package/@castleio/castle-js#configuration)
104
103
 
105
104
  ## How-Tos
106
105
 
@@ -23,7 +23,7 @@ module CastleDevise
23
23
  # <!-- the rest of your layout -->
24
24
  def castle_javascript_tag
25
25
  javascript_include_tag(
26
- "https://d2t77mnxyo7adj.cloudfront.net/v1/c.js?#{CastleDevise.configuration.app_id}"
26
+ "https://cdn.castle.io/v2/castle.js?#{CastleDevise.configuration.app_id}"
27
27
  )
28
28
  end
29
29
 
@@ -31,52 +31,14 @@ module CastleDevise
31
31
  # within the current form.
32
32
  #
33
33
  # @example
34
- # <%= form_for(resource, as: resource_name, url: sessions_path(resource_name)) do |f| %>
35
- # <%= castle_request_token %>
34
+ # <%= form_for(resource, as: resource_name, url: sessions_path(resource_name), html: { onsubmit: castle_on_form_submit }) do |f| %>
36
35
  # <%= f.email_field :email %>
37
36
  # <%= f.password_field :password, autocomplete: 'off' %>
38
37
  # <% end %>
39
38
  #
40
39
  # @return [String]
41
- def castle_request_token
42
- tag = <<~HEREDOC
43
- <script>
44
- // The current script tag is the last one at the time of load
45
- var el = document.getElementsByTagName('script');
46
- el = el[el.length - 1];
47
-
48
- // Traverse up until we find a form
49
- while (el && el !== document) {
50
- if (el.tagName === 'FORM') break;
51
- el = el.parentNode;
52
- }
53
-
54
- // Intercept the form submit
55
- if (el.tagName === 'FORM') {
56
- el.onsubmit = function(e) {
57
- e.preventDefault();
58
-
59
- _castle('createRequestToken').then(function(requestToken) {
60
- // Populate a hidden field called `castle_request_token` with the
61
- // request token
62
- var hiddenInput = document.createElement('input');
63
- hiddenInput.setAttribute('type', 'hidden');
64
- hiddenInput.setAttribute('name', 'castle_request_token');
65
- hiddenInput.setAttribute('value', requestToken);
66
-
67
- // Add the hidden field to the form so it gets sent to the server
68
- // before submitting the form
69
- el.appendChild(hiddenInput);
70
-
71
- el.submit();
72
- });
73
- };
74
- } else {
75
- console.log('[Castle] The script helper needs to be within a <form> tag')
76
- }
77
- </script>
78
- HEREDOC
79
- tag.html_safe
40
+ def castle_on_form_submit
41
+ "typeof(_castle)=='undefined'?event.preventDefault():_castle('onFormSubmit', event)"
80
42
  end
81
43
  end
82
44
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CastleDevise
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: castle_devise
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kacper Madej
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2021-08-12 00:00:00.000000000 Z
13
+ date: 2021-08-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  - !ruby/object:Gem::Version
141
141
  version: '0'
142
142
  requirements: []
143
- rubygems_version: 3.0.3
143
+ rubygems_version: 3.2.23
144
144
  signing_key:
145
145
  specification_version: 4
146
146
  summary: Integrates Castle with Devise