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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: be3fa05a1918b464de14937ad07e9b3d5a5bd7ca
4
- data.tar.gz: e88513a3098f8b8eba8ea10bfdb566c328907f62
3
+ metadata.gz: 37698c3c846ac9b834f5e54f61f0740d47aba30f
4
+ data.tar.gz: 648bfbe72f80db915cba1b00ccf01e197a5bb2a0
5
5
  SHA512:
6
- metadata.gz: 6ac13fb888f2db7a574c5093339dd7991b6443d0ec6e75d3a87245aac87be0a96118c928b635c6b5cdec3823fc5f76ac901abc0a8e669c182a07bdb8337aa6c0
7
- data.tar.gz: e56a24604e4f56c71f9eef07795317779aa129cc863aeaa5ab89b7eeacdba37e2e28b1b2ba69202f9a4c2fba50dcf928add5588e8cb010cb61c72e1279ec3f8d
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
- If the token matches the user `authentication_token`, it'll be set to `nil` and return `true`. If it doesn't match, errors will be added to `User#errors` and false will be returned.
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("auth_token")
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(auth_token)
17
- if auth_token == authentication_token
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(30)
22
+ SecureRandom.hex
28
23
  end
29
24
  end
30
25
 
@@ -1,3 +1,3 @@
1
1
  module RedTokenAuth
2
- VERSION = '0.3.0'
2
+ VERSION = '0.4.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: red_token_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Caio Ergos