devise_token_auth 1.0.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +4 -2
  3. data/app/controllers/devise_token_auth/application_controller.rb +19 -3
  4. data/app/controllers/devise_token_auth/concerns/resource_finder.rb +23 -11
  5. data/app/controllers/devise_token_auth/concerns/set_user_by_token.rb +78 -57
  6. data/app/controllers/devise_token_auth/confirmations_controller.rb +67 -20
  7. data/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb +82 -30
  8. data/app/controllers/devise_token_auth/passwords_controller.rb +53 -31
  9. data/app/controllers/devise_token_auth/registrations_controller.rb +33 -40
  10. data/app/controllers/devise_token_auth/sessions_controller.rb +24 -6
  11. data/app/controllers/devise_token_auth/unlocks_controller.rb +10 -6
  12. data/app/models/devise_token_auth/concerns/active_record_support.rb +14 -0
  13. data/app/models/devise_token_auth/concerns/confirmable_support.rb +28 -0
  14. data/app/models/devise_token_auth/concerns/mongoid_support.rb +19 -0
  15. data/app/models/devise_token_auth/concerns/tokens_serialization.rb +31 -0
  16. data/app/models/devise_token_auth/concerns/user.rb +77 -80
  17. data/app/models/devise_token_auth/concerns/user_omniauth_callbacks.rb +12 -5
  18. data/app/validators/{email_validator.rb → devise_token_auth_email_validator.rb} +11 -3
  19. data/app/views/devise_token_auth/omniauth_external_window.html.erb +1 -1
  20. data/config/locales/da-DK.yml +2 -0
  21. data/config/locales/de.yml +2 -0
  22. data/config/locales/en.yml +10 -0
  23. data/config/locales/es.yml +2 -0
  24. data/config/locales/fr.yml +2 -0
  25. data/config/locales/he.yml +52 -0
  26. data/config/locales/it.yml +2 -0
  27. data/config/locales/ja.yml +16 -2
  28. data/config/locales/ko.yml +51 -0
  29. data/config/locales/nl.yml +2 -0
  30. data/config/locales/pl.yml +6 -3
  31. data/config/locales/pt-BR.yml +2 -0
  32. data/config/locales/pt.yml +6 -3
  33. data/config/locales/ro.yml +2 -0
  34. data/config/locales/ru.yml +2 -0
  35. data/config/locales/sq.yml +2 -0
  36. data/config/locales/sv.yml +2 -0
  37. data/config/locales/uk.yml +2 -0
  38. data/config/locales/vi.yml +2 -0
  39. data/config/locales/zh-CN.yml +2 -0
  40. data/config/locales/zh-HK.yml +2 -0
  41. data/config/locales/zh-TW.yml +2 -0
  42. data/lib/devise_token_auth/blacklist.rb +6 -0
  43. data/lib/devise_token_auth/controllers/helpers.rb +5 -9
  44. data/lib/devise_token_auth/engine.rb +17 -2
  45. data/lib/devise_token_auth/rails/routes.rb +18 -13
  46. data/lib/devise_token_auth/token_factory.rb +126 -0
  47. data/lib/devise_token_auth/url.rb +3 -0
  48. data/lib/devise_token_auth/version.rb +1 -1
  49. data/lib/devise_token_auth.rb +6 -3
  50. data/lib/generators/devise_token_auth/USAGE +1 -1
  51. data/lib/generators/devise_token_auth/install_generator.rb +7 -91
  52. data/lib/generators/devise_token_auth/install_generator_helpers.rb +98 -0
  53. data/lib/generators/devise_token_auth/install_mongoid_generator.rb +46 -0
  54. data/lib/generators/devise_token_auth/templates/devise_token_auth.rb +13 -0
  55. data/lib/generators/devise_token_auth/templates/devise_token_auth_create_users.rb.erb +1 -8
  56. data/lib/generators/devise_token_auth/templates/user.rb.erb +2 -2
  57. data/lib/generators/devise_token_auth/templates/user_mongoid.rb.erb +56 -0
  58. data/test/controllers/custom/custom_confirmations_controller_test.rb +1 -1
  59. data/test/controllers/demo_mang_controller_test.rb +37 -8
  60. data/test/controllers/demo_user_controller_test.rb +39 -10
  61. data/test/controllers/devise_token_auth/confirmations_controller_test.rb +163 -18
  62. data/test/controllers/devise_token_auth/omniauth_callbacks_controller_test.rb +110 -43
  63. data/test/controllers/devise_token_auth/passwords_controller_test.rb +299 -122
  64. data/test/controllers/devise_token_auth/registrations_controller_test.rb +54 -14
  65. data/test/controllers/devise_token_auth/sessions_controller_test.rb +31 -40
  66. data/test/controllers/devise_token_auth/token_validations_controller_test.rb +43 -2
  67. data/test/controllers/devise_token_auth/unlocks_controller_test.rb +44 -5
  68. data/test/controllers/overrides/confirmations_controller_test.rb +1 -1
  69. data/test/dummy/app/active_record/confirmable_user.rb +11 -0
  70. data/test/dummy/app/{models → active_record}/scoped_user.rb +2 -2
  71. data/test/dummy/app/{models → active_record}/unconfirmable_user.rb +1 -2
  72. data/test/dummy/app/{models → active_record}/unregisterable_user.rb +3 -3
  73. data/test/dummy/app/active_record/user.rb +6 -0
  74. data/test/dummy/app/controllers/overrides/confirmations_controller.rb +3 -3
  75. data/test/dummy/app/controllers/overrides/passwords_controller.rb +3 -3
  76. data/test/dummy/app/controllers/overrides/registrations_controller.rb +1 -1
  77. data/test/dummy/app/controllers/overrides/sessions_controller.rb +2 -2
  78. data/test/dummy/app/models/{user.rb → concerns/favorite_color.rb} +7 -8
  79. data/test/dummy/app/mongoid/confirmable_user.rb +52 -0
  80. data/test/dummy/app/mongoid/lockable_user.rb +38 -0
  81. data/test/dummy/app/mongoid/mang.rb +46 -0
  82. data/test/dummy/app/mongoid/only_email_user.rb +33 -0
  83. data/test/dummy/app/mongoid/scoped_user.rb +50 -0
  84. data/test/dummy/app/mongoid/unconfirmable_user.rb +44 -0
  85. data/test/dummy/app/mongoid/unregisterable_user.rb +47 -0
  86. data/test/dummy/app/mongoid/user.rb +49 -0
  87. data/test/dummy/app/views/layouts/application.html.erb +0 -2
  88. data/test/dummy/config/application.rb +22 -1
  89. data/test/dummy/config/boot.rb +4 -0
  90. data/test/dummy/config/environments/development.rb +0 -10
  91. data/test/dummy/config/environments/production.rb +0 -16
  92. data/test/dummy/config/initializers/devise.rb +285 -0
  93. data/test/dummy/config/initializers/devise_token_auth.rb +35 -4
  94. data/test/dummy/config/initializers/figaro.rb +1 -1
  95. data/test/dummy/config/initializers/omniauth.rb +1 -0
  96. data/test/dummy/config/routes.rb +2 -0
  97. data/test/dummy/db/migrate/20140715061447_devise_token_auth_create_users.rb +0 -7
  98. data/test/dummy/db/migrate/20140715061805_devise_token_auth_create_mangs.rb +0 -7
  99. data/test/dummy/db/migrate/20141222035835_devise_token_auth_create_only_email_users.rb +0 -7
  100. data/test/dummy/db/migrate/20141222053502_devise_token_auth_create_unregisterable_users.rb +0 -7
  101. data/test/dummy/db/migrate/20150708104536_devise_token_auth_create_unconfirmable_users.rb +0 -7
  102. data/test/dummy/db/migrate/20160103235141_devise_token_auth_create_scoped_users.rb +0 -7
  103. data/test/dummy/db/migrate/20160629184441_devise_token_auth_create_lockable_users.rb +0 -7
  104. data/test/dummy/db/migrate/20190924101113_devise_token_auth_create_confirmable_users.rb +49 -0
  105. data/test/dummy/db/schema.rb +31 -33
  106. data/test/dummy/tmp/generators/app/models/user.rb +11 -0
  107. data/test/dummy/tmp/generators/config/initializers/devise_token_auth.rb +60 -0
  108. data/test/dummy/tmp/generators/db/migrate/20220822003050_devise_token_auth_create_users.rb +49 -0
  109. data/test/factories/users.rb +3 -2
  110. data/test/lib/devise_token_auth/blacklist_test.rb +19 -0
  111. data/test/lib/devise_token_auth/rails/custom_routes_test.rb +29 -0
  112. data/test/lib/devise_token_auth/rails/routes_test.rb +87 -0
  113. data/test/lib/devise_token_auth/token_factory_test.rb +191 -0
  114. data/test/lib/devise_token_auth/url_test.rb +2 -2
  115. data/test/lib/generators/devise_token_auth/install_generator_test.rb +51 -31
  116. data/test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb +51 -31
  117. data/test/models/concerns/mongoid_support_test.rb +31 -0
  118. data/test/models/concerns/tokens_serialization_test.rb +104 -0
  119. data/test/models/confirmable_user_test.rb +35 -0
  120. data/test/models/only_email_user_test.rb +0 -8
  121. data/test/models/user_test.rb +13 -23
  122. data/test/test_helper.rb +45 -4
  123. metadata +126 -33
  124. data/config/initializers/devise.rb +0 -198
  125. data/test/dummy/config/initializers/assets.rb +0 -10
  126. data/test/dummy/tmp/generators/app/views/devise/mailer/confirmation_instructions.html.erb +0 -5
  127. data/test/dummy/tmp/generators/app/views/devise/mailer/reset_password_instructions.html.erb +0 -8
  128. /data/test/dummy/app/{models → active_record}/lockable_user.rb +0 -0
  129. /data/test/dummy/app/{models → active_record}/mang.rb +0 -0
  130. /data/test/dummy/app/{models → active_record}/only_email_user.rb +0 -0
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bcrypt'
4
-
5
3
  module DeviseTokenAuth::Concerns::User
6
4
  extend ActiveSupport::Concern
7
5
 
@@ -9,7 +7,7 @@ module DeviseTokenAuth::Concerns::User
9
7
  @token_equality_cache ||= {}
10
8
 
11
9
  key = "#{token_hash}/#{token}"
12
- result = @token_equality_cache[key] ||= (::BCrypt::Password.new(token_hash) == token)
10
+ result = @token_equality_cache[key] ||= DeviseTokenAuth::TokenFactory.token_hash_is_token?(token_hash, token)
13
11
  @token_equality_cache = {} if @token_equality_cache.size > 10000
14
12
  result
15
13
  end
@@ -20,19 +18,21 @@ module DeviseTokenAuth::Concerns::User
20
18
  devise_modules.delete(:omniauthable)
21
19
  else
22
20
  devise :database_authenticatable, :registerable,
23
- :recoverable, :trackable, :validatable, :confirmable
21
+ :recoverable, :validatable, :confirmable
22
+ end
23
+
24
+ if const_defined?('ActiveRecord') && ancestors.include?(ActiveRecord::Base)
25
+ include DeviseTokenAuth::Concerns::ActiveRecordSupport
24
26
  end
25
27
 
26
- serialize :tokens, JSON unless tokens_has_json_column_type?
28
+ if const_defined?('Mongoid') && ancestors.include?(Mongoid::Document)
29
+ include DeviseTokenAuth::Concerns::MongoidSupport
30
+ end
27
31
 
28
32
  if DeviseTokenAuth.default_callbacks
29
33
  include DeviseTokenAuth::Concerns::UserOmniauthCallbacks
30
34
  end
31
35
 
32
- # can't set default on text fields in mysql, simulate here instead.
33
- after_save :set_empty_token_hash
34
- after_initialize :set_empty_token_hash
35
-
36
36
  # get rid of dead tokens
37
37
  before_save :destroy_expired_tokens
38
38
 
@@ -44,6 +44,10 @@ module DeviseTokenAuth::Concerns::User
44
44
  def email_changed?; false; end
45
45
  def will_save_change_to_email?; false; end
46
46
 
47
+ if DeviseTokenAuth.send_confirmation_email && devise_modules.include?(:confirmable)
48
+ include DeviseTokenAuth::Concerns::ConfirmableSupport
49
+ end
50
+
47
51
  def password_required?
48
52
  return false unless provider == 'email'
49
53
  super
@@ -84,39 +88,25 @@ module DeviseTokenAuth::Concerns::User
84
88
  send_devise_notification(:unlock_instructions, raw, opts)
85
89
  raw
86
90
  end
87
- end
88
-
89
- def create_token(client_id: nil, token: nil, expiry: nil, **token_extras)
90
- client_id ||= SecureRandom.urlsafe_base64(nil, false)
91
- token ||= SecureRandom.urlsafe_base64(nil, false)
92
- expiry ||= (Time.zone.now + token_lifespan).to_i
93
91
 
94
- tokens[client_id] = {
95
- token: BCrypt::Password.create(token),
96
- expiry: expiry
97
- }.merge!(token_extras)
92
+ def create_token(client: nil, lifespan: nil, cost: nil, **token_extras)
93
+ token = DeviseTokenAuth::TokenFactory.create(client: client, lifespan: lifespan, cost: cost)
98
94
 
99
- clean_old_tokens
95
+ tokens[token.client] = {
96
+ token: token.token_hash,
97
+ expiry: token.expiry
98
+ }.merge!(token_extras)
100
99
 
101
- [client_id, token, expiry]
102
- end
103
-
104
- module ClassMethods
105
- protected
106
-
107
- def tokens_has_json_column_type?
108
- database_exists? && table_exists? && columns_hash['tokens'] && columns_hash['tokens'].type.in?([:json, :jsonb])
109
- end
100
+ clean_old_tokens
110
101
 
111
- def database_exists?
112
- ActiveRecord::Base.connection_pool.with_connection { |con| con.active? } rescue false
102
+ token
113
103
  end
114
104
  end
115
105
 
116
- def valid_token?(token, client_id = 'default')
117
- return false unless tokens[client_id]
118
- return true if token_is_current?(token, client_id)
119
- return true if token_can_be_reused?(token, client_id)
106
+ def valid_token?(token, client = 'default')
107
+ return false unless tokens[client]
108
+ return true if token_is_current?(token, client)
109
+ return true if token_can_be_reused?(token, client)
120
110
 
121
111
  # return false if none of the above conditions are met
122
112
  false
@@ -126,10 +116,11 @@ module DeviseTokenAuth::Concerns::User
126
116
  # can be passed on from the client
127
117
  def send_confirmation_notification?; false; end
128
118
 
129
- def token_is_current?(token, client_id)
119
+ def token_is_current?(token, client)
130
120
  # ghetto HashWithIndifferentAccess
131
- expiry = tokens[client_id]['expiry'] || tokens[client_id][:expiry]
132
- token_hash = tokens[client_id]['token'] || tokens[client_id][:token]
121
+ expiry = tokens[client]['expiry'] || tokens[client][:expiry]
122
+ token_hash = tokens[client]['token'] || tokens[client][:token]
123
+ previous_token_hash = tokens[client]['previous_token'] || tokens[client][:previous_token]
133
124
 
134
125
  return true if (
135
126
  # ensure that expiry and token are set
@@ -139,58 +130,77 @@ module DeviseTokenAuth::Concerns::User
139
130
  DateTime.strptime(expiry.to_s, '%s') > Time.zone.now &&
140
131
 
141
132
  # ensure that the token is valid
142
- DeviseTokenAuth::Concerns::User.tokens_match?(token_hash, token)
133
+ (
134
+ # check if the latest token matches
135
+ does_token_match?(token_hash, token) ||
136
+
137
+ # check if the previous token matches
138
+ does_token_match?(previous_token_hash, token)
139
+ )
143
140
  )
144
141
  end
145
142
 
146
- # allow batch requests to use the previous token
147
- def token_can_be_reused?(token, client_id)
143
+ # check if the hash of received token matches the stored token
144
+ def does_token_match?(token_hash, token)
145
+ return false if token_hash.nil?
146
+
147
+ DeviseTokenAuth::Concerns::User.tokens_match?(token_hash, token)
148
+ end
149
+
150
+ # allow batch requests to use the last token
151
+ def token_can_be_reused?(token, client)
148
152
  # ghetto HashWithIndifferentAccess
149
- updated_at = tokens[client_id]['updated_at'] || tokens[client_id][:updated_at]
150
- last_token = tokens[client_id]['last_token'] || tokens[client_id][:last_token]
153
+ updated_at = tokens[client]['updated_at'] || tokens[client][:updated_at]
154
+ last_token_hash = tokens[client]['last_token'] || tokens[client][:last_token]
151
155
 
152
156
  return true if (
153
157
  # ensure that the last token and its creation time exist
154
- updated_at && last_token &&
158
+ updated_at && last_token_hash &&
155
159
 
156
- # ensure that previous token falls within the batch buffer throttle time of the last request
157
- Time.parse(updated_at) > Time.zone.now - DeviseTokenAuth.batch_request_buffer_throttle &&
160
+ # ensure that last token falls within the batch buffer throttle time of the last request
161
+ updated_at.to_time > Time.zone.now - DeviseTokenAuth.batch_request_buffer_throttle &&
158
162
 
159
163
  # ensure that the token is valid
160
- ::BCrypt::Password.new(last_token) == token
164
+ DeviseTokenAuth::TokenFactory.token_hash_is_token?(last_token_hash, token)
161
165
  )
162
166
  end
163
167
 
164
168
  # update user's auth token (should happen on each request)
165
- def create_new_auth_token(client_id = nil)
169
+ def create_new_auth_token(client = nil)
166
170
  now = Time.zone.now
167
171
 
168
- client_id, token = create_token(
169
- client_id: client_id,
170
- expiry: (now + token_lifespan).to_i,
171
- last_token: tokens.fetch(client_id, {})['token'],
172
+ token = create_token(
173
+ client: client,
174
+ previous_token: tokens.fetch(client, {})['token'],
175
+ last_token: tokens.fetch(client, {})['previous_token'],
172
176
  updated_at: now
173
177
  )
174
178
 
175
- update_auth_header(token, client_id)
179
+ update_auth_header(token.token, token.client)
176
180
  end
177
181
 
178
- def build_auth_header(token, client_id = 'default')
182
+ def build_auth_header(token, client = 'default')
179
183
  # client may use expiry to prevent validation request if expired
180
184
  # must be cast as string or headers will break
181
- expiry = tokens[client_id]['expiry'] || tokens[client_id][:expiry]
182
-
183
- {
185
+ expiry = tokens[client]['expiry'] || tokens[client][:expiry]
186
+ headers = {
184
187
  DeviseTokenAuth.headers_names[:"access-token"] => token,
185
188
  DeviseTokenAuth.headers_names[:"token-type"] => 'Bearer',
186
- DeviseTokenAuth.headers_names[:"client"] => client_id,
189
+ DeviseTokenAuth.headers_names[:"client"] => client,
187
190
  DeviseTokenAuth.headers_names[:"expiry"] => expiry.to_s,
188
191
  DeviseTokenAuth.headers_names[:"uid"] => uid
189
192
  }
193
+ headers.merge!(build_bearer_token(headers))
194
+ end
195
+
196
+ def build_bearer_token(auth)
197
+ encoded_token = Base64.strict_encode64(auth.to_json)
198
+ bearer_token = "Bearer #{encoded_token}"
199
+ {DeviseTokenAuth.headers_names[:"authorization"] => bearer_token}
190
200
  end
191
201
 
192
- def update_auth_header(token, client_id = 'default')
193
- headers = build_auth_header(token, client_id)
202
+ def update_auth_header(token, client = 'default')
203
+ headers = build_auth_header(token, client)
194
204
  clean_old_tokens
195
205
  save!
196
206
 
@@ -204,9 +214,9 @@ module DeviseTokenAuth::Concerns::User
204
214
  DeviseTokenAuth::Url.generate(base_url, args)
205
215
  end
206
216
 
207
- def extend_batch_buffer(token, client_id)
208
- tokens[client_id]['updated_at'] = Time.zone.now
209
- update_auth_header(token, client_id)
217
+ def extend_batch_buffer(token, client)
218
+ tokens[client]['updated_at'] = Time.zone.now
219
+ update_auth_header(token, client)
210
220
  end
211
221
 
212
222
  def confirmed?
@@ -217,16 +227,8 @@ module DeviseTokenAuth::Concerns::User
217
227
  as_json(except: %i[tokens created_at updated_at])
218
228
  end
219
229
 
220
- def token_lifespan
221
- DeviseTokenAuth.token_lifespan
222
- end
223
-
224
230
  protected
225
231
 
226
- def set_empty_token_hash
227
- self.tokens ||= {} if has_attribute?(:tokens)
228
- end
229
-
230
232
  def destroy_expired_tokens
231
233
  if tokens
232
234
  tokens.delete_if do |cid, v|
@@ -237,21 +239,16 @@ module DeviseTokenAuth::Concerns::User
237
239
  end
238
240
 
239
241
  def should_remove_tokens_after_password_reset?
240
- if Rails::VERSION::MAJOR <= 5
241
- encrypted_password_changed? &&
242
- DeviseTokenAuth.remove_tokens_after_password_reset
243
- else
244
- saved_change_to_encrypted_password? &&
245
- DeviseTokenAuth.remove_tokens_after_password_reset
246
- end
242
+ DeviseTokenAuth.remove_tokens_after_password_reset &&
243
+ (respond_to?(:encrypted_password_changed?) && encrypted_password_changed?)
247
244
  end
248
245
 
249
246
  def remove_tokens_after_password_reset
250
247
  return unless should_remove_tokens_after_password_reset?
251
248
 
252
249
  if tokens.present? && tokens.many?
253
- client_id, token_data = tokens.max_by { |cid, v| v[:expiry] || v['expiry'] }
254
- self.tokens = { client_id => token_data }
250
+ client, token_data = tokens.max_by { |cid, v| v[:expiry] || v['expiry'] }
251
+ self.tokens = { client => token_data }
255
252
  end
256
253
  end
257
254
 
@@ -4,12 +4,12 @@ module DeviseTokenAuth::Concerns::UserOmniauthCallbacks
4
4
  extend ActiveSupport::Concern
5
5
 
6
6
  included do
7
- validates :email, presence: true,if: :email_provider?
8
- validates :email, email: true, allow_nil: true, allow_blank: true, if: :email_provider?
9
- validates_presence_of :uid, unless: :email_provider?
7
+ validates :email, presence: true, if: lambda { uid_and_provider_defined? && email_provider? }
8
+ validates :email, :devise_token_auth_email => true, allow_nil: true, allow_blank: true, if: lambda { uid_and_provider_defined? && email_provider? }
9
+ validates_presence_of :uid, if: lambda { uid_and_provider_defined? && !email_provider? }
10
10
 
11
11
  # only validate unique emails among email registration users
12
- validates :email, uniqueness: { scope: :provider }, on: :create, if: :email_provider?
12
+ validates :email, uniqueness: { case_sensitive: false, scope: :provider }, on: :create, if: lambda { uid_and_provider_defined? && email_provider? }
13
13
 
14
14
  # keep uid in sync with email
15
15
  before_save :sync_uid
@@ -18,11 +18,18 @@ module DeviseTokenAuth::Concerns::UserOmniauthCallbacks
18
18
 
19
19
  protected
20
20
 
21
+ def uid_and_provider_defined?
22
+ defined?(provider) && defined?(uid)
23
+ end
24
+
21
25
  def email_provider?
22
26
  provider == 'email'
23
27
  end
24
28
 
25
29
  def sync_uid
26
- self.uid = email if provider == 'email'
30
+ unless self.new_record?
31
+ return if devise_modules.include?(:confirmable) && !@bypass_confirmation_postpone && postpone_email_change?
32
+ end
33
+ self.uid = email if uid_and_provider_defined? && email_provider?
27
34
  end
28
35
  end
@@ -1,9 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class EmailValidator < ActiveModel::EachValidator
3
+ class DeviseTokenAuthEmailValidator < ActiveModel::EachValidator
4
+ EMAIL_REGEXP = /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
5
+
6
+ class << self
7
+ def validate?(email)
8
+ email =~ EMAIL_REGEXP
9
+ end
10
+ end
11
+
4
12
  def validate_each(record, attribute, value)
5
- unless value =~ /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
6
- record.errors[attribute] << email_invalid_message
13
+ unless DeviseTokenAuthEmailValidator.validate?(value)
14
+ record.errors.add(attribute, email_invalid_message)
7
15
  end
8
16
  end
9
17
 
@@ -15,7 +15,7 @@
15
15
  Cordova / PhoneGap)
16
16
  */
17
17
 
18
- var data = JSON.parse(decodeURIComponent('<%= URI::escape( @data.to_json ) %>'));
18
+ var data = JSON.parse(decodeURIComponent('<%= ERB::Util.url_encode( @data.to_json ) %>'));
19
19
 
20
20
  window.addEventListener("message", function(ev) {
21
21
  if (ev.data === "requestCredentials") {
@@ -14,6 +14,8 @@ da-DK:
14
14
  account_with_uid_destroyed: "Kontoen med UID '%{uid}' er slettet."
15
15
  account_to_destroy_not_found: "Kan ikke finde kontoen som skal slettes."
16
16
  user_not_found: "Brugeren ikke fundet."
17
+ omniauth:
18
+ not_allowed_redirect_url: "Omdirigering til '%{redirect_url}' er ikke tilladt."
17
19
  passwords:
18
20
  missing_email: "Du skal udfylde email feltet."
19
21
  missing_redirect_url: "Der er ingen omdirigeringsadresse."
@@ -14,6 +14,8 @@ de:
14
14
  account_with_uid_destroyed: "Account mit der uid '%{uid}' wurde gelöscht."
15
15
  account_to_destroy_not_found: "Der zu löschende Account kann nicht gefunden werden."
16
16
  user_not_found: "Benutzer kann nicht gefunden werden."
17
+ omniauth:
18
+ not_allowed_redirect_url: "Weiterleitung zu '%{redirect_url}' ist nicht gestattet."
17
19
  passwords:
18
20
  missing_email: "Sie müssen eine E-Mail-Adresse angeben."
19
21
  missing_redirect_url: "Es fehlt die URL zu Weiterleitung."
@@ -14,11 +14,14 @@ en:
14
14
  account_with_uid_destroyed: "Account with UID '%{uid}' has been destroyed."
15
15
  account_to_destroy_not_found: "Unable to locate account for destruction."
16
16
  user_not_found: "User not found."
17
+ omniauth:
18
+ not_allowed_redirect_url: "Redirect to '%{redirect_url}' not allowed."
17
19
  passwords:
18
20
  missing_email: "You must provide an email address."
19
21
  missing_redirect_url: "Missing redirect URL."
20
22
  not_allowed_redirect_url: "Redirect to '%{redirect_url}' not allowed."
21
23
  sended: "An email has been sent to '%{email}' containing instructions for resetting your password."
24
+ sended_paranoid: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
22
25
  user_not_found: "Unable to find user with email '%{email}'."
23
26
  password_not_required: "This account does not require a password. Sign in using your '%{provider}' account instead."
24
27
  missing_passwords: "You must fill out the fields labeled 'Password' and 'Password confirmation'."
@@ -26,7 +29,14 @@ en:
26
29
  unlocks:
27
30
  missing_email: "You must provide an email address."
28
31
  sended: "An email has been sent to '%{email}' containing instructions for unlocking your account."
32
+ sended_paranoid: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes."
33
+ user_not_found: "Unable to find user with email '%{email}'."
34
+ confirmations:
35
+ sended: "An email has been sent to '%{email}' containing instructions for confirming your account."
36
+ sended_paranoid: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes."
29
37
  user_not_found: "Unable to find user with email '%{email}'."
38
+ missing_email: "You must provide an email address."
39
+
30
40
  errors:
31
41
  messages:
32
42
  validate_sign_up_params: "Please submit proper sign up data in request body."
@@ -14,6 +14,8 @@ es:
14
14
  account_with_uid_destroyed: "La cuenta con el identificador '%{uid}' se ha eliminado."
15
15
  account_to_destroy_not_found: "No se puede encontrar la cuenta a borrar."
16
16
  user_not_found: "Usuario no encontrado."
17
+ omniauth:
18
+ not_allowed_redirect_url: "Redirección hacia '%{redirect_url}' no esta permitida."
17
19
  passwords:
18
20
  missing_email: "Debe incluir un correo electrónico."
19
21
  missing_redirect_url: "Falta el Url de redirección."
@@ -14,6 +14,8 @@ fr:
14
14
  account_with_uid_destroyed: "Le compte avec l'identifiant '%{uid}' a été supprimé."
15
15
  account_to_destroy_not_found: "Le compte à supprimer est introuvable."
16
16
  user_not_found: "Utilisateur introuvable."
17
+ omniauth:
18
+ not_allowed_redirect_url: "Redirection vers '%{redirect_url}' n'est pas autorisée."
17
19
  passwords:
18
20
  missing_email: "Vous devez soumettre un e-mail."
19
21
  missing_redirect_url: "URL de redirection manquante."
@@ -0,0 +1,52 @@
1
+ he:
2
+ devise_token_auth:
3
+ sessions:
4
+ not_confirmed: "הודעת אישור נשלחה לחשבון שלך בכתובת '%{email}'. עליך לפעול לפי ההנחיות שבדוא\"ל לפני הפעלת החשבון שלך"
5
+ bad_credentials: "נתוני כניסה שגויים. בבקשה נסה שוב."
6
+ not_supported: "השתמש ב- POST / sign_in כדי להיכנס. GET אינו נתמך."
7
+ user_not_found: "המשתמש לא נמצא או לא היה מחובר."
8
+ token_validations:
9
+ invalid: "נתוני כניסה שגויים"
10
+ registrations:
11
+ missing_confirm_success_url: "חסר פרמטר 'confirm_success_url'."
12
+ redirect_url_not_allowed: "הפניה אל '%{redirect_url}' אינה מותרת."
13
+ email_already_exists: "כבר קיים חשבון עבור '%{email}'"
14
+ account_with_uid_destroyed: "חשבון עם UID '%{uid}' הושמד."
15
+ account_to_destroy_not_found: "לא ניתן לאתר חשבון להשמדה."
16
+ user_not_found: "המשתמש לא נמצא."
17
+ omniauth:
18
+ not_allowed_redirect_url: "הפניה אל '%{redirect_url}' אינה מותרת."
19
+ passwords:
20
+ missing_email: "עליך לספק כתובת דוא\"ל."
21
+ missing_redirect_url: "כתובת אתר להפניה מחדש חסרה."
22
+ not_allowed_redirect_url: "הפניה אל '%{redirect_url}' אינה מותרת."
23
+ sended: "אימייל נשלח ל '%{email}' המכיל הוראות לאיפוס הסיסמה שלך."
24
+ user_not_found: "לא ניתן למצוא משתמש עם הדוא\"ל '%{email}'."
25
+ password_not_required: "חשבון זה אינו דורש סיסמה. במקום זאת, השתמש בחשבון '%{provider}' שלך."
26
+ missing_passwords: "עליך למלא את השדות 'סיסמה' ו'אישור סיסמה'."
27
+ successfully_updated: "הסיסמה שלך עודכנה בהצלחה."
28
+ unlocks:
29
+ missing_email: "עליך לספק כתובת דוא\"ל."
30
+ sended: "הודעת אימייל נשלחה אל '%{email}' המכילה הוראות לביטול הנעילה של חשבונך."
31
+ user_not_found: "ניתן למצוא את המשתמש עם הדוא\"ל '%{email}'"
32
+ errors:
33
+ messages:
34
+ validate_sign_up_params: "שלח נתוני רישום תקינים בגוף הבקשה."
35
+ validate_account_update_params: "שלחו בבקשה נתוני עדכון חשבון תקינים בגוף הבקשה."
36
+ not_email: "אינו דוא\"ל"
37
+ devise:
38
+ mailer:
39
+ confirmation_instructions:
40
+ confirm_link_msg: "תוכל לאשר את כתובת הדוא\"ל של החשבון שלך באמצעות הקישור הבא:"
41
+ confirm_account_link: "אשר את החשבון שלי"
42
+ reset_password_instructions:
43
+ request_reset_link_msg: "מישהו ביקש קישור לשינוי הסיסמה שלך. תוכל לעשות זאת באמצעות הקישור הבא."
44
+ password_change_link: "שנה את הסיסמה שלי"
45
+ ignore_mail_msg: "אם לא ביקשת זאת, התעלם מדוא\"ל זה."
46
+ no_changes_msg: "הסיסמה שלך לא תשתנה עד שתגיע לקישור שלמעלה ותיצור סיסמה חדשה."
47
+ unlock_instructions:
48
+ account_lock_msg: "החשבון שלך ננעל עקב מספר מופרז של ניסיונות כניסה לא מוצלחים."
49
+ unlock_link_msg: "לחץ על הקישור למטה כדי לבטל את נעילת החשבון שלך:"
50
+ unlock_link: "בטל את הנעילה של החשבון שלי"
51
+ hello: "שלום"
52
+ welcome: "ברוך הבא"
@@ -14,6 +14,8 @@ it:
14
14
  account_with_uid_destroyed: "L'account con UID '%{uid}' è stato eliminato."
15
15
  account_to_destroy_not_found: "Impossibile trovare l'account da eliminare."
16
16
  user_not_found: "Utente non trovato."
17
+ omniauth:
18
+ not_allowed_redirect_url: "Redirezione a '%{redirect_url}' non consentita."
17
19
  passwords:
18
20
  missing_email: "Devi fornire un indirizzo email."
19
21
  missing_redirect_url: "Redirect URL mancante."
@@ -14,27 +14,41 @@ ja:
14
14
  account_with_uid_destroyed: "'%{uid}' のアカウントは削除されました。"
15
15
  account_to_destroy_not_found: "削除するアカウントが見つかりません。"
16
16
  user_not_found: "ユーザーが見つかりません。"
17
+ omniauth:
18
+ not_allowed_redirect_url: "'%{redirect_url}' へのリダイレクトは許可されていません。"
17
19
  passwords:
18
20
  missing_email: "メールアドレスが与えられていません。"
19
21
  missing_redirect_url: "リダイレクト URL が与えられていません。"
20
22
  not_allowed_redirect_url: "'%{redirect_url}' へのリダイレクトは許可されていません。"
21
23
  sended: "'%{email}' にパスワードリセットの案内が送信されました。"
24
+ sended_paranoid: "すでにメールアドレスがデータベースに登録されている場合、 数分後にパスワード再発行用のリンクを記載したメールをお送りします。"
22
25
  user_not_found: "メールアドレス '%{email}' のユーザーが見つかりません。"
23
26
  password_not_required: "このアカウントはパスワードを要求していません。'%{provider}' を利用してログインしてください。"
24
27
  missing_passwords: "'Password', 'Password confirmation' パラメータが与えられていません。"
25
28
  successfully_updated: "パスワードの更新に成功しました。"
29
+ unlocks:
30
+ missing_email: "メールアドレスが与えられていません。"
31
+ sended: "%{email}' にアカウントのロックを解除する方法を記載したメールが送信されました。"
32
+ sended_paranoid: "アカウントが存在する場合、数分後にロックを解除する方法を記載したメールをお送りします。"
33
+ user_not_found: "メールアドレス '%{email}' を持つユーザーが見つかりません。"
34
+ confirmations:
35
+ sended: "'%{email}' にアカウントの確認方法を記載したメールが送信されました。"
36
+ sended_paranoid: "すでにメールアドレスがデータベースに登録されている場合、数分後にメールアドレスの確認方法を記載したメールをお送りします。"
37
+ user_not_found: "メールアドレス '%{email}' を持つユーザーが見つかりません。"
38
+ missing_email: "メールアドレスが与えられていません。"
39
+
26
40
  errors:
27
41
  messages:
28
42
  validate_sign_up_params: "リクエストボディに適切なアカウント新規登録データを送信してください。"
29
43
  validate_account_update_params: "リクエストボディに適切なアカウント更新のデータを送信してください。"
30
- not_email: "はメールアドレスではありません"
44
+ not_email: "は有効ではありません"
31
45
  devise:
32
46
  mailer:
33
47
  confirmation_instructions:
34
48
  confirm_link_msg: "下記のリンクからアカウントを有効化できます:"
35
49
  confirm_account_link: "アカウントを有効化する"
36
50
  reset_password_instructions:
37
- request_reset_link_msg: "パスワード変更のリクエストが送信されました。下記のリンクからパスワードの変更をできます。"
51
+ request_reset_link_msg: "パスワード変更のリクエストが送信されました。下記のリンクからパスワードの変更ができます。"
38
52
  password_change_link: "パスワードを変更する"
39
53
  ignore_mail_msg: "もしこの内容に覚えがない場合は、このメールを無視してください。"
40
54
  no_changes_msg: "上記のリンクにアクセスして新しいパスワードを作成するまで、現在のパスワードは変更されません。"
@@ -0,0 +1,51 @@
1
+ ko:
2
+ devise_token_auth:
3
+ sessions:
4
+ not_confirmed: "'%{email}'로 주소 인증 메일을 발송했습니다. 계정을 활성화하기 위해서는 반드시 메일의 안내를 따라야 합니다."
5
+ bad_credentials: "계정 정보가 맞지 않습니다. 다시 시도해 주세요."
6
+ not_supported: "POST /sign_in to sign in을 사용해주세요. GET은 지원하지 않습니다."
7
+ user_not_found: "유저를 찾을 수 없습니다."
8
+ invalid: "계정 정보가 맞지 않습니다."
9
+ registrations:
10
+ missing_confirm_success_url: "'confirm_success_url' 파라미터가 없습니다."
11
+ redirect_url_not_allowed: "'%{redirect_url}' 주소로 리다이렉트는 허용하지 않습니다."
12
+ email_already_exists: "'%{email}'을 사용하는 계정이 이미 있습니다."
13
+ account_with_uid_destroyed: " UID가 '%{uid}'인 계정을 삭제했습니다."
14
+ account_to_destroy_not_found: "삭제할 계정을 찾을 수 없습니다."
15
+ user_not_found: "유저를 찾을 수 없습니다."
16
+ omniauth:
17
+ not_allowed_redirect_url: "'%{redirect_url}' 주소로 리다이렉트는 허용하지 않습니다."
18
+ passwords:
19
+ missing_email: "이메일 주소를 입력해야 합니다."
20
+ missing_redirect_url: "redirect URL이 없습니다."
21
+ not_allowed_redirect_url: "'%{redirect_url}' 주소로 리다이렉트는 허용하지 않습니다."
22
+ sended: "'%{email}'로 비밀번호를 재설정하기 위한 안내 메일을 발송했습니다."
23
+ user_not_found: "'%{email}'을 사용하는 유저를 찾을 수 없습니다."
24
+ password_not_required: "이 계정은 비밀번호가 필요하지 않습니다. '%{provider}'으로 로그인을 진행해 주세요."
25
+ missing_passwords: "비밀번호와 비밀번호 확인 필드를 반드시 입력해야 합니다."
26
+ successfully_updated: "비밀번호를 성공적으로 업데이트 했습니다."
27
+ unlocks:
28
+ missing_email: "이메일 주소를 반드시 입력해야 합니다."
29
+ sended: "'%{email}'로 계정 잠금 해제를 위한 안내 메일을 발송했습니다."
30
+ user_not_found: "'%{email}'을 사용하는 유저를 찾을 수 없습니다."
31
+ errors:
32
+ messages:
33
+ validate_sign_up_params: "요청 값에 알맞은 로그인 데이터를 입력하세요."
34
+ validate_account_update_params: "요청 값에 알맞은 업데이트 데이터를 입력하세요."
35
+ not_email: "이메일이 아닙니다."
36
+ devise:
37
+ mailer:
38
+ confirmation_instructions:
39
+ confirm_link_msg: "아래의 링크를 이용해 계정 인증을 할 수 있습니다."
40
+ confirm_account_link: "본인 계정 인증"
41
+ reset_password_instructions:
42
+ request_reset_link_msg: "누군가 당신의 비밀번호를 변경하는 링크를 요청했으며, 다음의 링크에서 비밀번호 변경이 가능합니다."
43
+ password_change_link: "비밀번호 변경"
44
+ ignore_mail_msg: "비밀번호 변경을 요청하지 않으셨다면 이 메일을 무시하십시오."
45
+ no_changes_msg: "위 링크에 접속하여 새로운 비밀번호를 생성하기 전까지 귀하의 비밀번호는 변경되지 않습니다."
46
+ unlock_instructions:
47
+ account_lock_msg: "로그인 실패 횟수 초과로 귀하의 계정이 잠금 처리되었습니다."
48
+ unlock_link_msg: "계정 잠금을 해제하려면 아래 링크를 클릭하세요."
49
+ unlock_link: "계정 잠금 해제"
50
+ hello: "안녕하세요"
51
+ welcome: "환영합니다"
@@ -14,6 +14,8 @@ nl:
14
14
  account_with_uid_destroyed: "Account met id '%{uid}' is verwijderd."
15
15
  account_to_destroy_not_found: "Te verwijderen account niet gevonden."
16
16
  user_not_found: "Gebruiker niet gevonden."
17
+ omniauth:
18
+ not_allowed_redirect_url: "Redirect naar '%{redirect_url}' niet toegestaan."
17
19
  passwords:
18
20
  missing_email: "Je moet een e-mailadres opgeven."
19
21
  missing_redirect_url: "Redirect URL ontbreekt."
@@ -14,6 +14,8 @@ pl:
14
14
  account_with_uid_destroyed: "Konto z uid '%{uid}' zostało usunięte."
15
15
  account_to_destroy_not_found: "Nie odnaleziono konta do usunięcia."
16
16
  user_not_found: "Użytkownik nie został odnaleziony."
17
+ omniauth:
18
+ not_allowed_redirect_url: "Przekierowanie na adres '%{redirect_url}' nie jest dozwolone."
17
19
  passwords:
18
20
  missing_email: "Musisz wprowadzić adres e-mail."
19
21
  missing_redirect_url: "Brak adresu zwrotnego."
@@ -24,9 +26,10 @@ pl:
24
26
  missing_passwords: "Musisz wypełnić wszystkie pola z etykietą 'Hasło' oraz 'Potwierdzenie hasła'."
25
27
  successfully_updated: "Twoje hasło zostało zaktualizowane."
26
28
  errors:
27
- validate_sign_up_params: "Proszę dostarczyć odpowiednie dane logowania w ciele zapytania."
28
- validate_account_update_params: "Proszę dostarczyć odpowiednie dane aktualizacji konta w ciele zapytania."
29
- not_email: "nie jest prawidłowym adresem e-mail"
29
+ messages:
30
+ validate_sign_up_params: "Proszę dostarczyć odpowiednie dane logowania w ciele zapytania."
31
+ validate_account_update_params: "Proszę dostarczyć odpowiednie dane aktualizacji konta w ciele zapytania."
32
+ not_email: "nie jest prawidłowym adresem e-mail"
30
33
  devise:
31
34
  mailer:
32
35
  confirmation_instructions:
@@ -14,6 +14,8 @@ pt-BR:
14
14
  account_with_uid_destroyed: "A conta com uid '%{uid}' foi excluída."
15
15
  account_to_destroy_not_found: "Não foi possível encontrar a conta para exclusão."
16
16
  user_not_found: "Usuário não encontrado."
17
+ omniauth:
18
+ not_allowed_redirect_url: "Redirecionamento para '%{redirect_url}' não permitido."
17
19
  passwords:
18
20
  missing_email: "Informe o endereço de e-mail."
19
21
  missing_redirect_url: "URL para redirecionamento não informada."
@@ -14,6 +14,8 @@ pt:
14
14
  account_with_uid_destroyed: "A conta com uid '%{uid}' foi excluída."
15
15
  account_to_destroy_not_found: "Não foi possível encontrar a conta para exclusão."
16
16
  user_not_found: "Utilizador não encontrado."
17
+ omniauth:
18
+ not_allowed_redirect_url: "Redirecionamento para '%{redirect_url}' não permitido."
17
19
  passwords:
18
20
  missing_email: "Informe o endereço de e-mail."
19
21
  missing_redirect_url: "URL para redirecionamento não informada."
@@ -24,9 +26,10 @@ pt:
24
26
  missing_passwords: "Preencha a senha e a confirmação de senha."
25
27
  successfully_updated: "Senha atualizada com sucesso."
26
28
  errors:
27
- validate_sign_up_params: "Os dados submetidos na requisição de registo são inválidos."
28
- validate_account_update_params: "Os dados submetidos para atualização de conta são inválidos."
29
- not_email: "não é um e-mail"
29
+ messages:
30
+ validate_sign_up_params: "Os dados submetidos na requisição de registo são inválidos."
31
+ validate_account_update_params: "Os dados submetidos para atualização de conta são inválidos."
32
+ not_email: "não é um e-mail"
30
33
  devise:
31
34
  mailer:
32
35
  confirmation_instructions: