user_management_rails 0.1.2 → 0.1.3
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
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d26237abd546dc567c3c508e567c03909662314e
|
4
|
+
data.tar.gz: aa42c2835c583367dd4682853bd2449cd0f64da8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74fa1447354efcaad4913f4bc0eee786067b089abca2643bd0870beb103cc1094a1c8b537bd44641033857869ff9224164310fad0aeb6f380731e12e17aa3d52
|
7
|
+
data.tar.gz: ffa80971185a17fff43de03b23fe47b81e81cf3828e52e1a732baa71cdbd473070b90131f27a44761666692fa3bc62877c4ed03c17acf1a1a674b97d66f2f8cf
|
data/README.md
CHANGED
@@ -16,10 +16,13 @@ Gem provides current_user_hash method for your controller by adding next line to
|
|
16
16
|
```ruby
|
17
17
|
include UserManagementRails::Concerns::UserResource
|
18
18
|
```
|
19
|
+
It has one optional param `raise_jwt_error` which when true (by default) will rise exception if user jwt has expired.
|
20
|
+
If you don't want to raise exception then pass `false` and when token is expired then jwt will be deleted for cookies.
|
21
|
+
|
19
22
|
How it works:
|
20
23
|
* If there is no jwt in cookies then return null
|
21
|
-
* If jwt is invalid
|
22
|
-
* If jwt is expired
|
24
|
+
* If jwt is invalid or expired and raise_jwt_error is true then it raise an error
|
25
|
+
* If jwt is invalid or expired and raise_jwt_error is false then it return nil and delete jwt from cookies.
|
23
26
|
* If there is valid and not expired jwt in cookies then it returns a hash of user details
|
24
27
|
|
25
28
|
## Installation
|
@@ -3,9 +3,21 @@ require_dependency 'user_management_rails/application_controller'
|
|
3
3
|
module UserManagementRails::Concerns::UserResource
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
|
-
def current_user_hash
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
def current_user_hash(raise_jwt_error = true)
|
7
|
+
result = nil
|
8
|
+
begin
|
9
|
+
user_jwt = cookies[:jwt]
|
10
|
+
result = UserManagementRails.decode_user(user_jwt) if user_jwt
|
11
|
+
rescue => error
|
12
|
+
raise if raise_jwt_error
|
13
|
+
handle_error
|
14
|
+
end
|
15
|
+
result
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def handle_error
|
21
|
+
cookies.delete! :jwt
|
10
22
|
end
|
11
23
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: user_management_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- RingCaptcha
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -236,7 +236,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
236
236
|
version: '0'
|
237
237
|
requirements: []
|
238
238
|
rubyforge_project:
|
239
|
-
rubygems_version: 2.
|
239
|
+
rubygems_version: 2.6.11
|
240
240
|
signing_key:
|
241
241
|
specification_version: 4
|
242
242
|
summary: RingCaptcha widget RoR helper.
|