rails_jwt_auth 0.16.2 → 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8d5a4666390b7e5ba3ee3366b0c684a1b459c5ce
4
- data.tar.gz: 62b7b394da8f777d054b2fb2ea13035c9c221870
3
+ metadata.gz: f1b219bb8ec23bd8bcb9e32a01ac0a2b1ff65ad3
4
+ data.tar.gz: 661143484c1f4affd78cf5ec8e484b52b8b35d48
5
5
  SHA512:
6
- metadata.gz: 0416d3617556a3071c39353187744b298f9b49ea5ddc6dd8c193d7eb2d86559aacce12054b1497204723da697b9eab3192c47bc8034b0c3a1894c8a8410a755a
7
- data.tar.gz: 4526394f0134f278e5adb2bf03f1ef92ae70a15b40ed403ef8df0e7be14ae9878bceacda87f301eb9e06fed1e0b88e2d48d85ee9afab9f72017994f085649d4d
6
+ metadata.gz: b25885a2765a541534f041c5e313781a46076810332d1275494b510d465103fd59716ceddcf41d4eda7b2615e2a29285a82c08eb1282b059cb4d30401e60278b
7
+ data.tar.gz: b9a62d4b102d13e55fc20ccbe442bfda9deadb5c854b872ec65d1425093068aecc5b3cdc3407ff510eaf8d1f37b92f38ddf115a358c1f9f5a59b6ccf77fb24ec
data/README.md CHANGED
@@ -37,6 +37,7 @@ You can edit configuration options into `config/initializers/auth_token_auth.rb`
37
37
  | model_name | 'User' | Authentication model name |
38
38
  | auth_field_name | 'email' | Field used to authenticate user with password |
39
39
  | auth_field_email | true | Validate auth field email format |
40
+ | email_regex | see config file | Regex used to Validate email format |
40
41
  | jwt_expiration_time | 7.days | Tokens expiration time |
41
42
  | jwt_issuer | 'RailsJwtAuth' | The "iss" (issuer) claim identifies the principal that issued the JWT |
42
43
  | simultaneous_sessions | 2 | Number of simultaneous sessions for an user |
@@ -11,6 +11,10 @@ module RailsJwtAuth
11
11
  end
12
12
 
13
13
  def update
14
+ if params[:confirmation_token].blank?
15
+ return render_422(confirmation_token: [I18n.t('rails_jwt_auth.errors.not_found')])
16
+ end
17
+
14
18
  user = RailsJwtAuth.model.where(confirmation_token: params[:confirmation_token]).first
15
19
  return render_422(confirmation_token: [I18n.t('rails_jwt_auth.errors.not_found')]) unless user
16
20
 
@@ -11,6 +11,10 @@ module RailsJwtAuth
11
11
  end
12
12
 
13
13
  def update
14
+ if params[:reset_password_token].blank?
15
+ return render_422(reset_password_token: [I18n.t('rails_jwt_auth.errors.not_found')])
16
+ end
17
+
14
18
  user = RailsJwtAuth.model.where(reset_password_token: params[:reset_password_token]).first
15
19
 
16
20
  unless user
@@ -62,6 +62,10 @@ module RailsJwtAuth
62
62
 
63
63
  base.send(:has_secure_password)
64
64
 
65
+ base.send(:before_validation) do
66
+ self.email = email.downcase if self.email
67
+ end
68
+
65
69
  base.extend(ClassMethods)
66
70
  end
67
71
  end
@@ -1,6 +1,6 @@
1
1
  class EmailValidator < ActiveModel::EachValidator
2
2
  def validate_each(record, attribute, value)
3
- unless value =~ /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
3
+ unless value =~ RailsJwtAuth.email_regex
4
4
  record.errors[attribute] << (options[:message] || I18n.t('rails_jwt_auth.errors.email.invalid'))
5
5
  end
6
6
  end
@@ -8,6 +8,9 @@ RailsJwtAuth.setup do |config|
8
8
  # set to true to validate auth_field email format
9
9
  #config.auth_field_email = true
10
10
 
11
+ # regex used to Validate email format
12
+ #config.email_regex = /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
13
+
11
14
  # expiration time for generated tokens
12
15
  #config.jwt_expiration_time = 7.days
13
16
 
@@ -15,7 +18,7 @@ RailsJwtAuth.setup do |config|
15
18
  #config.jwt_issuer = 'RailsJwtAuth'
16
19
 
17
20
  # number of simultaneously sessions for an user
18
- #config.simultaneously_sessions = 3
21
+ #config.simultaneously_sessions = 2
19
22
 
20
23
  # mailer sender
21
24
  #config.mailer_sender = 'initialize-mailer_sender@example.com'
@@ -29,6 +32,9 @@ RailsJwtAuth.setup do |config|
29
32
  # url used to create email link with reset password token
30
33
  #config.reset_password_url = 'http://frontend.com/reset_password'
31
34
 
35
+ # url used to create email link with set password token
36
+ #config.set_password_url = 'http://frontend.com/set_password'
37
+
32
38
  # expiration time for reset password tokens
33
39
  #config.reset_password_expiration_time = 1.day
34
40
 
@@ -13,6 +13,9 @@ module RailsJwtAuth
13
13
  mattr_accessor :auth_field_email
14
14
  @@auth_field_email = true
15
15
 
16
+ mattr_accessor :email_regex
17
+ @@email_regex = /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
18
+
16
19
  mattr_accessor :jwt_expiration_time
17
20
  @@jwt_expiration_time = 7.days
18
21
 
@@ -23,7 +26,7 @@ module RailsJwtAuth
23
26
  @@simultaneous_sessions = 2
24
27
 
25
28
  mattr_accessor :mailer_sender
26
- @@mailer_sender = "initialize-mailer_sender@example.com"
29
+ @@mailer_sender = 'initialize-mailer_sender@example.com'
27
30
 
28
31
  mattr_accessor :confirmation_url
29
32
  @@confirmation_url = nil
@@ -1,3 +1,3 @@
1
1
  module RailsJwtAuth
2
- VERSION = '0.16.2'
2
+ VERSION = '0.17.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_jwt_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.2
4
+ version: 0.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - rjurado
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-26 00:00:00.000000000 Z
11
+ date: 2017-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -126,8 +126,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
126
  version: '0'
127
127
  requirements: []
128
128
  rubyforge_project:
129
- rubygems_version: 2.5.2
129
+ rubygems_version: 2.4.5.1
130
130
  signing_key:
131
131
  specification_version: 4
132
132
  summary: Rails jwt authentication.
133
133
  test_files: []
134
+ has_rdoc: