proof-rails 1.0.0 → 1.1.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
  SHA1:
3
- metadata.gz: 49f2a44ddd6d526589c80ae83d0de56a01208541
4
- data.tar.gz: 43d90dde4af4e545181d5e9ccd3576d3fd03700a
3
+ metadata.gz: 72f782aa4df0bc5f3d58996705e8ba3c2276a592
4
+ data.tar.gz: 0ec8f337510ebc81303f505d08a79902683b6c91
5
5
  SHA512:
6
- metadata.gz: 195e90c8d2ae50efe39b6f23a924149684523685f7f666ca0230f0ae28ee03089711bdb7e815c00af868e82f53eb0bf708ac0139354d501cf4dd081d7d5be51f
7
- data.tar.gz: 015c18c02064d7dad2784c10e4b9878034e821e59f1f09c1541381921f68bb2dcf4a2ab3b283eb72d9d2b9dcc6330f1bc2c49c8ece3b4dd90c06aa52e567ccc3
6
+ metadata.gz: bec1a5234f7c0a500423b01888830308507b71ce15709a4ca926007b724309d0289ff040bcc359b0d7d8812ff03cf525d2dd4c421f01b08b7bbe286ce10d570c
7
+ data.tar.gz: c20c63967c2173bde2c499345fc326049a37ed224f1962fd5318005c1cf0147f3af39a63275bce3fe036858ea56914d52ae9bec3755f7b2cd70e7e91a696ef74
@@ -2,11 +2,15 @@ module Proof
2
2
  module RequireProof
3
3
  extend ActiveSupport::Concern
4
4
 
5
- def require_proof
5
+ def require_proof(options={})
6
+ options[:authenticatable] ||= :User
7
+
6
8
  raw_token = request.headers['Authorization'].split(' ').last if request.headers['Authorization']
7
9
  token = Proof::Token.from_token(raw_token) if raw_token
8
10
 
9
- @current_user ||= User.find_by_id(token.data[:user_id]) if token
11
+ proof_class = options[:authenticatable].to_s.camelize.constantize
12
+
13
+ @current_user ||= proof_class.find_by_id(token.data[:user_id]) if token
10
14
 
11
15
  render json: { error: 'Not Authorized' }, status: :unauthorized unless @current_user
12
16
  end
data/lib/proof/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Proof
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proof-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Hobohm