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 +4 -4
- data/lib/proof/require_proof.rb +6 -2
- data/lib/proof/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72f782aa4df0bc5f3d58996705e8ba3c2276a592
|
4
|
+
data.tar.gz: 0ec8f337510ebc81303f505d08a79902683b6c91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bec1a5234f7c0a500423b01888830308507b71ce15709a4ca926007b724309d0289ff040bcc359b0d7d8812ff03cf525d2dd4c421f01b08b7bbe286ce10d570c
|
7
|
+
data.tar.gz: c20c63967c2173bde2c499345fc326049a37ed224f1962fd5318005c1cf0147f3af39a63275bce3fe036858ea56914d52ae9bec3755f7b2cd70e7e91a696ef74
|
data/lib/proof/require_proof.rb
CHANGED
@@ -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
|
-
|
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