authform-rails 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/authform/rails/concern.rb +32 -22
- data/lib/authform/rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b38c9d775b5e9861d131ce83c0525ea036c1650b89c7fab83cfb7b294e7e349
|
4
|
+
data.tar.gz: 857853905a28f5bd2270d8df9ae2ec862f105f17774ac37ea39cc895f507bfca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a28bf0004e36d4f765d022dbbf8244092cbb180f70fb36ac2c528fcdb332ff013777009b1c528539b8e7fe30434bfce72a43af91a2f305d1fbdf72c72823329
|
7
|
+
data.tar.gz: 46c3ce5bf584903a592fe69ef8150ab740426a4b8463188b7466023015bb767e9711671009e2c5f20c1af6c4dd378a0fca07b6035f334818131a299fee7669b1
|
data/Gemfile.lock
CHANGED
@@ -1,34 +1,44 @@
|
|
1
1
|
module Authform
|
2
2
|
module Rails
|
3
|
-
|
4
|
-
|
3
|
+
class Concern < Module
|
4
|
+
def initialize(form_uuid:)
|
5
|
+
super() do
|
6
|
+
extend ActiveSupport::Concern
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
included do
|
9
|
+
helper_method :current_user
|
10
|
+
before_action :_exchange_voucher_for_user
|
11
|
+
end
|
10
12
|
|
11
|
-
|
13
|
+
private
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
define_method :current_user do
|
16
|
+
begin
|
17
|
+
JSON.parse(cookies[authform_user_cookie_key])["data"]
|
18
|
+
rescue
|
19
|
+
nil
|
20
|
+
end
|
21
|
+
end
|
18
22
|
|
19
|
-
|
20
|
-
|
21
|
-
|
23
|
+
define_method :_exchange_voucher_for_user do
|
24
|
+
if params[:_authformVoucher]
|
25
|
+
response = Faraday.get("https://api.authform.io/v1/exchangeVoucherForUser.json", { formUuid: form_uuid, voucher: params[:_authformVoucher] })
|
22
26
|
|
23
|
-
|
24
|
-
|
25
|
-
|
27
|
+
if response.status == 200
|
28
|
+
cookies[authform_user_cookie_key] = response.body
|
29
|
+
end
|
30
|
+
|
31
|
+
q = Rack::Utils.parse_query(URI.parse(request.url).query)
|
32
|
+
q.delete("_authformVoucher")
|
33
|
+
url = q.empty? ? request.path : "#{request.path}?#{q.to_query}"
|
26
34
|
|
27
|
-
|
28
|
-
|
29
|
-
|
35
|
+
redirect_to url, status: 302 # redirect to finish removal of query param
|
36
|
+
end
|
37
|
+
end
|
30
38
|
|
31
|
-
|
39
|
+
define_method :authform_user_cookie_key do
|
40
|
+
"user#{form_uuid}"
|
41
|
+
end
|
32
42
|
end
|
33
43
|
end
|
34
44
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authform-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gatleon
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|