challah-jwt 0.2.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7c3fcba21e9b182c4522ceef036a576dc980409d
4
- data.tar.gz: ae4e5f372f24f542bf9c1018461395e7af1e7347
3
+ metadata.gz: 24a7006305ca4a2c167a60fe9cff8b48c4e355fc
4
+ data.tar.gz: 0013cd81f2cc458f3d79c84fa7e1afb962c26728
5
5
  SHA512:
6
- metadata.gz: 9cc59e0ab65029e3e5534453ff9b307915195d220817e9dd83da0bd6dfced1087aeaefab55562a0ae19b4f2bbd9a50bf88f5248d33483bba51ae93d0fdb9e4a1
7
- data.tar.gz: '0379a709decc5837e6b5188f2a67222b4bba2e0782aa13027707bc23162d97b25b97481c6558a6b9e0a87565f8aa9b2835b23ba2d19bad96ae4b4eda97d28d67'
6
+ metadata.gz: e14e19ba9ac251374dbc2e8fba9d47eee81c62f7372bff91c5bdf6a58b4cbaa733669a4a2cdc7648f29ab70e4732378d46b88b8dbd07e679c4f9b9b25d9dbb8c
7
+ data.tar.gz: 5b3926ca3ac358743da052888d14bed18ab9a0883f0123017c7d47dbc678103c85e7f4d607bb7ea6ff9395797bf1ce1b8a44494fd26cd01f908aeddaa3165e07
@@ -10,7 +10,7 @@ module Challah
10
10
  payload = ::JWT.decode(token, Challah::Jwt.secret_key)
11
11
  id = payload.dig(0, jwt_root, "id")
12
12
 
13
- if Challah::Jwt.configuration.use_api_key
13
+ if Challah::Jwt.configuration.use_api_key && column_names.include?("api_key")
14
14
  api_key = payload.dig(0, jwt_root, "api_key")
15
15
  find_by(id: id, api_key: api_key)
16
16
  else
@@ -20,6 +20,10 @@ module Challah
20
20
  nil
21
21
  end
22
22
 
23
+ def find_by_jwt!(token)
24
+ find_by_jwt(token) or raise ActiveRecord::RecordNotFound.new("Couldn't find #{self.name} with [jwt=#{token.to_s.truncate(25)}]")
25
+ end
26
+
23
27
  def jwt_root
24
28
  model_name.singular
25
29
  end
@@ -1,5 +1,5 @@
1
1
  module Challah
2
2
  module Jwt
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: challah-jwt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Phillip Ridlen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-20 00:00:00.000000000 Z
11
+ date: 2017-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: challah
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
105
  version: '0'
106
106
  requirements: []
107
107
  rubyforge_project:
108
- rubygems_version: 2.5.2
108
+ rubygems_version: 2.6.8
109
109
  signing_key:
110
110
  specification_version: 4
111
111
  summary: Use JSON Web Tokens (JWT) to authenticate with Challah