authform-rails 0.1.0 → 0.1.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/Gemfile.lock +5 -1
- data/authform-rails.gemspec +4 -2
- data/lib/authform/rails/concern.rb +36 -0
- data/lib/authform/rails/version.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de7779b0d3b0564f8ffdd9071b11a7565668754aa7bf62ef6fa90fc7e2436d1c
|
4
|
+
data.tar.gz: 0022f927b30ba96ba1f023e635f5ee8af178ba097a74b9ce26970b0ecbaf68bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a310094865cec70b8cad0d7aee5d7fa68d52d65fd429dcecd7d282572f03748fe51c1fe05680cae14e9b8258cb65ba65381879c36a3676819a2e2a418b8a1d3
|
7
|
+
data.tar.gz: e1604cdeff47ffbcc13d417085d8d2e5ae973841227f552eae18750ace4c69dbe769e0ee303dc8b46652625e2c70c2158e800440ad95566d169ef01789fa5b8b
|
data/Gemfile.lock
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
authform-rails (0.1.
|
4
|
+
authform-rails (0.1.1)
|
5
|
+
faraday
|
5
6
|
|
6
7
|
GEM
|
7
8
|
remote: https://rubygems.org/
|
8
9
|
specs:
|
9
10
|
diff-lcs (1.3)
|
11
|
+
faraday (1.0.0)
|
12
|
+
multipart-post (>= 1.2, < 3)
|
13
|
+
multipart-post (2.1.1)
|
10
14
|
rake (12.3.3)
|
11
15
|
rspec (3.9.0)
|
12
16
|
rspec-core (~> 3.9.0)
|
data/authform-rails.gemspec
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative "lib/authform/rails/version"
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "authform-rails"
|
@@ -18,10 +18,12 @@ Gem::Specification.new do |spec|
|
|
18
18
|
|
19
19
|
# Specify which files should be added to the gem when it is released.
|
20
20
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
21
|
-
spec.files = Dir.chdir(File.expand_path(
|
21
|
+
spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
|
22
22
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
23
23
|
end
|
24
24
|
spec.bindir = "exe"
|
25
25
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
26
|
spec.require_paths = ["lib"]
|
27
|
+
|
28
|
+
spec.add_runtime_dependency "faraday"
|
27
29
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Authform
|
2
|
+
module Rails
|
3
|
+
module Concern
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
helper_method :authform_current_user
|
8
|
+
before_action :check_for_authform_voucher
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def authform_current_user
|
14
|
+
JSON.parse(cookies[:_authform_current_user])["data"]
|
15
|
+
rescue
|
16
|
+
nil
|
17
|
+
end
|
18
|
+
|
19
|
+
def check_for_authform_voucher
|
20
|
+
if params[:_authformVoucher]
|
21
|
+
response = Faraday.get("#{Rails.application.credentials.root_url}/v1/exchangeVoucherForUser.json", { voucher: params[:_authformVoucher] })
|
22
|
+
|
23
|
+
if response.status == 200
|
24
|
+
cookies[:_authform_current_user] = response.body
|
25
|
+
end
|
26
|
+
|
27
|
+
q = Rack::Utils.parse_query(URI.parse(request.url).query)
|
28
|
+
q.delete("_authformVoucher")
|
29
|
+
url = q.empty? ? request.path : "#{request.path}?#{q.to_query}"
|
30
|
+
|
31
|
+
redirect_to url, status: 302 # redirect to finish removal of query param
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authform-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gatleon
|
@@ -9,7 +9,21 @@ autorequire:
|
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
11
|
date: 2020-02-02 00:00:00.000000000 Z
|
12
|
-
dependencies:
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
description: Description
|
14
28
|
email:
|
15
29
|
- gatleon
|
@@ -29,6 +43,7 @@ files:
|
|
29
43
|
- bin/console
|
30
44
|
- bin/setup
|
31
45
|
- lib/authform/rails.rb
|
46
|
+
- lib/authform/rails/concern.rb
|
32
47
|
- lib/authform/rails/version.rb
|
33
48
|
homepage: https://github.com/gatleon
|
34
49
|
licenses:
|