tinytokenauth-rails 0.1.6 → 0.1.7

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
  SHA256:
3
- metadata.gz: a51cd8dbe7faddbd28aa43eab713a841bb3ea8b629d4753c949e522e09627048
4
- data.tar.gz: 35168279b0cb122da90c5a56502adb804e15f3f05b5bfe96a2a238dd7179ca53
3
+ metadata.gz: c9b10e6633d4606de4ec2969019871de80021a50126afac2c928abcb69ecf403
4
+ data.tar.gz: ab5f071a30e1408bc4467dc797607962f1b68d035954287aae753b959b4aa479
5
5
  SHA512:
6
- metadata.gz: '08f62d165b73b1b0e0e9517643b143e708e40600dfdf7bdbbbb1fe4cb6daa02d53c808bac82c5feaef1d3d8a71831ffbbac55f9c08ef0ba80f9e6a6161ae29b2'
7
- data.tar.gz: 5cb15b86e8d527860b646155a49f7dc318346f6d96a3a91876c53e6fdf5b9d18b8275661e96aceef537cc01943b868e6837089f325351efd4446fa760cd8212a
6
+ metadata.gz: a90e3dc70c6e8d28265862f23cdb9eb8581f6220fa13ed4d1428118227cefb1131e7e2ed5083666ba8e0d070ae48ef506eb343ab2b40d355c76c8a1d5234df41
7
+ data.tar.gz: 57be5affdbfbf2b5205077627c59115c1f0bf756ac12df2d3fe82cd89bd37acef5d7e868519ae0ea9f1e39e91336a27d1575e58f8e9b048fceafa5a8b87e7db9
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tinytokenauth-rails (0.1.6)
4
+ tinytokenauth-rails (0.1.7)
5
5
  jwt (~> 2.7)
6
6
  rails (>= 6.0)
7
7
 
@@ -1,15 +1,17 @@
1
1
  module Tinytokenauth
2
2
 
3
- module Authorizable
4
- class << self
5
- def configuration
6
- @configuration ||= Configuration.new
7
- end
3
+ class << self
4
+ def configuration
5
+ @configuration ||= Configuration.new
6
+ end
8
7
 
9
- def configure
10
- yield(configuration)
11
- end
8
+ def configure
9
+ yield(configuration)
12
10
  end
11
+ end
12
+
13
+ module Authorizable
14
+
13
15
 
14
16
  def authorize_with_header
15
17
  token = ''
@@ -19,7 +21,7 @@ module Tinytokenauth
19
21
  begin
20
22
  @decoded = JsonWebToken.decode(token)
21
23
  # @current_user = User.find(@decoded[:user_id])
22
- @current_user = Authorizable.configuration.user_class.send 'find', @decoded[:user_id]
24
+ @current_user = Tinytokenauth.configuration.user_class.send 'find', @decoded[:user_id]
23
25
  rescue ActiveRecord::RecordNotFound => e
24
26
  render json: { errors: e.message }, status: :unauthorized
25
27
  rescue JWT::DecodeError => e
@@ -60,15 +62,15 @@ module Tinytokenauth
60
62
  # end
61
63
 
62
64
  def require_current_user(&block)
63
- token = cookies[Authorizable.configuration.cookie_name]
65
+ token = cookies[Tinytokenauth.configuration.cookie_name]
64
66
  # p "token from cookie: #{token}"
65
67
  begin
66
68
  @decoded = JsonWebToken.decode(token)
67
69
  # @current_user = User.find(@decoded[:user_id])
68
- @current_user = Authorizable.configuration.user_class.send 'find', @decoded[:user_id]
70
+ @current_user = Tinytokenauth.configuration.user_class.send 'find', @decoded[:user_id]
69
71
  @exp = @decoded[:exp]
70
- if Authorizable.configuration.token_auto_renew_hours &&
71
- @exp < Authorizable.configuration.token_auto_renew_hours.hours.from_now.to_i
72
+ if Tinytokenauth.configuration.token_auto_renew_hours &&
73
+ @exp < Tinytokenauth.configuration.token_auto_renew_hours.hours.from_now.to_i
72
74
  sign_in @current_user
73
75
  end
74
76
  rescue ActiveRecord::RecordNotFound, JWT::DecodeError => e
@@ -115,9 +117,9 @@ module Tinytokenauth
115
117
  def sign_in(user)
116
118
  @current_user = user
117
119
  jwt = JsonWebToken.encode(user_id: user.id,
118
- exp: Authorizable.configuration.token_validity_hours.hours.from_now,
119
- secret: Authorizable.configuration.token_secret)
120
- cookies[Authorizable.configuration.cookie_name] = jwt
120
+ exp: Tinytokenauth.configuration.token_validity_hours.hours.from_now,
121
+ secret: Tinytokenauth.configuration.token_secret)
122
+ cookies[Tinytokenauth.configuration.cookie_name] = jwt
121
123
  end
122
124
 
123
125
  def current_user
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tinytokenauth
4
- VERSION = "0.1.6"
4
+ VERSION = "0.1.7"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tinytokenauth-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kim Laplume