red_token_auth 0.3.0 → 0.4.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/README.md +5 -7
- data/lib/red_token_auth/sign_in_out.rb +3 -8
- data/lib/red_token_auth/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: 37698c3c846ac9b834f5e54f61f0740d47aba30f
|
4
|
+
data.tar.gz: 648bfbe72f80db915cba1b00ccf01e197a5bb2a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9abfc95f64dfd0c248ae7515809981613e73b71565953a628c65d57795982b68babd05ad87b0bae43fdb419e576c49fbbd0a9966ecfddef6dd4941a3dfc4b8fc
|
7
|
+
data.tar.gz: b2b27205515f131d53154def7d88871c95e6ac1d897c399ede2329a04e909a8df4cc492524d09c67d44371455424b8e5017712c9a3a3e0da98a8330e93b7eff9
|
data/README.md
CHANGED
@@ -36,7 +36,7 @@ You'll be able to include the module in the model like so.
|
|
36
36
|
class User
|
37
37
|
include Mongoid::Document
|
38
38
|
include RedTokenAuth
|
39
|
-
|
39
|
+
|
40
40
|
# Mandatory fields for this gem.
|
41
41
|
field :email, type: String
|
42
42
|
field :password_digest, type: String
|
@@ -58,12 +58,12 @@ Authenticating the user:
|
|
58
58
|
class UsersController < ApplicationController
|
59
59
|
before_action only: [:update] { authenticate! :admin }
|
60
60
|
before_action only: [:show] { authenticate! :user }
|
61
|
-
|
61
|
+
|
62
62
|
def update
|
63
63
|
@admin = current_admin
|
64
64
|
# Code ...
|
65
65
|
end
|
66
|
-
|
66
|
+
|
67
67
|
def show
|
68
68
|
@user = current_user
|
69
69
|
end
|
@@ -82,10 +82,10 @@ By using the `authenticate!(:user)` in your controller, you'll have access to `c
|
|
82
82
|
|
83
83
|
* `User#sign_out`
|
84
84
|
|
85
|
-
|
85
|
+
The user's `authentication_token` will be set to `nil`. Returns `true` if the update is successful and `false` Otherwise.
|
86
86
|
|
87
87
|
```ruby
|
88
|
-
user.sign_out
|
88
|
+
user.sign_out
|
89
89
|
```
|
90
90
|
|
91
91
|
* `User#generate_password_token`
|
@@ -121,5 +121,3 @@ end
|
|
121
121
|
|
122
122
|
## License
|
123
123
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
124
|
-
|
125
|
-
|
@@ -13,18 +13,13 @@ module RedTokenAuth
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
def sign_out
|
17
|
-
|
18
|
-
update(authentication_token: nil)
|
19
|
-
else
|
20
|
-
errors.add(:authentication_token, :wrong_token)
|
21
|
-
false
|
22
|
-
end
|
16
|
+
def sign_out
|
17
|
+
update(authentication_token: nil)
|
23
18
|
end
|
24
19
|
end
|
25
20
|
|
26
21
|
def random_token
|
27
|
-
SecureRandom.hex
|
22
|
+
SecureRandom.hex
|
28
23
|
end
|
29
24
|
end
|
30
25
|
|