usps-jwt_auth 0.2.7 → 0.3.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/Gemfile.lock +1 -1
- data/lib/usps/jwt_auth/concern.rb +14 -3
- data/lib/usps/jwt_auth/incorrect_login.rb +7 -0
- data/lib/usps/jwt_auth/version.rb +1 -1
- data/lib/usps/jwt_auth.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a7b812b3bd3cd3dbaf68b5e3d0659c91ac872a9852dbd2e9da849a6f74676cdf
|
|
4
|
+
data.tar.gz: 5d033a22ad91830bf7971ef4a3239febe1a5bafb733100b4ea086741c3778eed
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2f21bdd0c4436166fd1556b33087dfa669f818d355b807424c1bc6e62f1ce68807a9521e92f4fda2306c9552e837fc120f8543f4dcfef1891e71958d5fa21518
|
|
7
|
+
data.tar.gz: 3f33edaba5c9c85e508c6c6d0b94f753939e9a37a224024a42eea189114ed14b6509b518e2559439f6b7f271dc61fba01ad3108d51de5f1cfa622e6d7a5d7b5f
|
data/Gemfile.lock
CHANGED
|
@@ -5,6 +5,7 @@ module Usps
|
|
|
5
5
|
# Controller helpers for handling JWT authentication
|
|
6
6
|
#
|
|
7
7
|
module Concern
|
|
8
|
+
# Gem rspec skips this block
|
|
8
9
|
if defined?(ActiveSupport::Concern)
|
|
9
10
|
extend ActiveSupport::Concern
|
|
10
11
|
|
|
@@ -41,7 +42,7 @@ module Usps
|
|
|
41
42
|
###############
|
|
42
43
|
|
|
43
44
|
def current_user_from_jwt
|
|
44
|
-
reset_session if params
|
|
45
|
+
reset_session if params.key?(:logout)
|
|
45
46
|
return if set_new_jwt
|
|
46
47
|
|
|
47
48
|
load_current_user if fetch_jwt.present?
|
|
@@ -70,8 +71,9 @@ module Usps
|
|
|
70
71
|
return if params[:jwt].blank?
|
|
71
72
|
|
|
72
73
|
store_jwt(params[:jwt])
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
ensure_valid_jwt_has_valid_member!
|
|
75
|
+
|
|
76
|
+
redirect_to(params[:path] || root_path)
|
|
75
77
|
end
|
|
76
78
|
|
|
77
79
|
def store_jwt(token)
|
|
@@ -110,6 +112,15 @@ module Usps
|
|
|
110
112
|
redirect_to(url, allow_other_host: true)
|
|
111
113
|
end
|
|
112
114
|
|
|
115
|
+
def ensure_valid_jwt_has_valid_member!
|
|
116
|
+
fetch_jwt
|
|
117
|
+
jwt_user
|
|
118
|
+
rescue ActiveRecord::RecordNotFound
|
|
119
|
+
clear_jwt
|
|
120
|
+
@current_user = nil
|
|
121
|
+
raise IncorrectLogin, 'Valid login without valid member record'
|
|
122
|
+
end
|
|
123
|
+
|
|
113
124
|
def stub_jwt!
|
|
114
125
|
raise 'Cannot stub JWT outside of test environment!' unless JwtAuth.config.environment.test?
|
|
115
126
|
|
data/lib/usps/jwt_auth.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: usps-jwt_auth
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Julian Fiander
|
|
@@ -86,6 +86,7 @@ files:
|
|
|
86
86
|
- lib/usps/jwt_auth/config.rb
|
|
87
87
|
- lib/usps/jwt_auth/decode.rb
|
|
88
88
|
- lib/usps/jwt_auth/encode.rb
|
|
89
|
+
- lib/usps/jwt_auth/incorrect_login.rb
|
|
89
90
|
- lib/usps/jwt_auth/railtie.rb
|
|
90
91
|
- lib/usps/jwt_auth/version.rb
|
|
91
92
|
- sig/usps_jwt/auth.rbs
|