devise_token_auth 1.1.0 → 1.1.5
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 +2 -0
- data/app/controllers/devise_token_auth/application_controller.rb +2 -2
- data/app/controllers/devise_token_auth/concerns/set_user_by_token.rb +28 -31
- data/app/controllers/devise_token_auth/confirmations_controller.rb +55 -7
- data/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb +34 -11
- data/app/controllers/devise_token_auth/passwords_controller.rb +32 -14
- data/app/controllers/devise_token_auth/registrations_controller.rb +6 -5
- data/app/controllers/devise_token_auth/sessions_controller.rb +5 -5
- data/app/controllers/devise_token_auth/unlocks_controller.rb +3 -3
- data/app/models/devise_token_auth/concerns/active_record_support.rb +1 -21
- data/app/models/devise_token_auth/concerns/confirmable_support.rb +28 -0
- data/app/models/devise_token_auth/concerns/tokens_serialization.rb +31 -0
- data/app/models/devise_token_auth/concerns/user.rb +43 -48
- data/app/models/devise_token_auth/concerns/user_omniauth_callbacks.rb +5 -2
- data/app/validators/{devise_token_auth/email_validator.rb → devise_token_auth_email_validator.rb} +2 -2
- data/config/locales/da-DK.yml +2 -0
- data/config/locales/de.yml +2 -0
- data/config/locales/en.yml +7 -0
- data/config/locales/es.yml +2 -0
- data/config/locales/fr.yml +2 -0
- data/config/locales/he.yml +2 -0
- data/config/locales/it.yml +2 -0
- data/config/locales/ja.yml +3 -1
- data/config/locales/ko.yml +51 -0
- data/config/locales/nl.yml +2 -0
- data/config/locales/pl.yml +6 -3
- data/config/locales/pt-BR.yml +2 -0
- data/config/locales/pt.yml +6 -3
- data/config/locales/ro.yml +2 -0
- data/config/locales/ru.yml +2 -0
- data/config/locales/sq.yml +2 -0
- data/config/locales/sv.yml +2 -0
- data/config/locales/uk.yml +2 -0
- data/config/locales/vi.yml +2 -0
- data/config/locales/zh-CN.yml +2 -0
- data/config/locales/zh-HK.yml +2 -0
- data/config/locales/zh-TW.yml +2 -0
- data/lib/devise_token_auth.rb +1 -0
- data/lib/devise_token_auth/controllers/helpers.rb +5 -9
- data/lib/devise_token_auth/engine.rb +7 -1
- data/lib/devise_token_auth/rails/routes.rb +16 -11
- data/lib/devise_token_auth/token_factory.rb +126 -0
- data/lib/devise_token_auth/url.rb +3 -0
- data/lib/devise_token_auth/version.rb +1 -1
- data/lib/generators/devise_token_auth/USAGE +1 -1
- data/lib/generators/devise_token_auth/install_generator.rb +4 -4
- data/lib/generators/devise_token_auth/install_mongoid_generator.rb +2 -2
- data/lib/generators/devise_token_auth/templates/devise_token_auth.rb +10 -0
- data/lib/generators/devise_token_auth/templates/devise_token_auth_create_users.rb.erb +1 -1
- data/lib/generators/devise_token_auth/templates/user.rb.erb +2 -2
- data/lib/generators/devise_token_auth/templates/user_mongoid.rb.erb +2 -2
- data/test/controllers/demo_user_controller_test.rb +2 -2
- data/test/controllers/devise_token_auth/confirmations_controller_test.rb +43 -0
- data/test/controllers/devise_token_auth/omniauth_callbacks_controller_test.rb +107 -42
- data/test/controllers/devise_token_auth/passwords_controller_test.rb +112 -8
- data/test/controllers/devise_token_auth/registrations_controller_test.rb +3 -3
- data/test/dummy/app/active_record/confirmable_user.rb +11 -0
- data/test/dummy/app/controllers/overrides/confirmations_controller.rb +3 -3
- data/test/dummy/app/controllers/overrides/passwords_controller.rb +3 -3
- data/test/dummy/app/controllers/overrides/registrations_controller.rb +1 -1
- data/test/dummy/app/controllers/overrides/sessions_controller.rb +1 -1
- data/test/dummy/app/mongoid/confirmable_user.rb +52 -0
- data/test/dummy/app/views/layouts/application.html.erb +0 -2
- data/test/dummy/config/application.rb +0 -1
- data/test/dummy/config/environments/development.rb +0 -10
- data/test/dummy/config/environments/production.rb +0 -16
- data/test/dummy/config/initializers/devise.rb +275 -2
- data/test/dummy/config/initializers/devise_token_auth.rb +35 -4
- data/test/dummy/config/initializers/figaro.rb +1 -1
- data/test/dummy/config/initializers/omniauth.rb +1 -0
- data/test/dummy/config/routes.rb +2 -0
- data/test/dummy/db/migrate/20190924101113_devise_token_auth_create_confirmable_users.rb +49 -0
- data/test/dummy/db/schema.rb +26 -1
- data/test/dummy/tmp/generators/app/models/azpire/v1/human_resource/user.rb +2 -2
- data/test/dummy/tmp/generators/config/initializers/devise_token_auth.rb +10 -0
- data/test/dummy/tmp/generators/db/migrate/{20190112150327_devise_token_auth_create_azpire_v1_human_resource_users.rb → 20210126004321_devise_token_auth_create_azpire_v1_human_resource_users.rb} +1 -8
- data/test/factories/users.rb +3 -2
- data/test/lib/devise_token_auth/rails/custom_routes_test.rb +29 -0
- data/test/lib/devise_token_auth/rails/routes_test.rb +87 -0
- data/test/lib/devise_token_auth/token_factory_test.rb +191 -0
- data/test/lib/devise_token_auth/url_test.rb +2 -2
- data/test/lib/generators/devise_token_auth/install_generator_test.rb +1 -1
- data/test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb +1 -1
- data/test/models/concerns/tokens_serialization_test.rb +104 -0
- data/test/models/confirmable_user_test.rb +35 -0
- data/test/models/user_test.rb +0 -32
- data/test/test_helper.rb +1 -1
- metadata +46 -17
- data/test/dummy/config/initializers/assets.rb +0 -10
- data/test/dummy/tmp/generators/config/routes.rb +0 -4
@@ -28,11 +28,12 @@ module DeviseTokenAuth
|
|
28
28
|
end
|
29
29
|
|
30
30
|
# if whitelist is set, validate redirect_url against whitelist
|
31
|
-
return render_create_error_redirect_url_not_allowed if blacklisted_redirect_url?
|
31
|
+
return render_create_error_redirect_url_not_allowed if blacklisted_redirect_url?(@redirect_url)
|
32
32
|
|
33
33
|
# override email confirmation, must be sent manually from ctrl
|
34
|
-
|
35
|
-
resource_class.
|
34
|
+
callback_name = defined?(ActiveRecord) && resource_class < ActiveRecord::Base ? :commit : :create
|
35
|
+
resource_class.set_callback(callback_name, :after, :send_on_create_confirmation_instructions)
|
36
|
+
resource_class.skip_callback(callback_name, :after, :send_on_create_confirmation_instructions)
|
36
37
|
|
37
38
|
if @resource.respond_to? :skip_confirmation_notification!
|
38
39
|
# Fix duplicate e-mails by disabling Devise confirmation e-mail
|
@@ -52,7 +53,7 @@ module DeviseTokenAuth
|
|
52
53
|
|
53
54
|
if active_for_authentication?
|
54
55
|
# email auth has been bypassed, authenticate user
|
55
|
-
@
|
56
|
+
@token = @resource.create_token
|
56
57
|
@resource.save!
|
57
58
|
update_auth_header
|
58
59
|
end
|
@@ -181,7 +182,7 @@ module DeviseTokenAuth
|
|
181
182
|
elsif account_update_params.key?(:current_password)
|
182
183
|
'update_with_password'
|
183
184
|
else
|
184
|
-
'
|
185
|
+
'update'
|
185
186
|
end
|
186
187
|
end
|
187
188
|
|
@@ -26,7 +26,7 @@ module DeviseTokenAuth
|
|
26
26
|
if (@resource.respond_to?(:valid_for_authentication?) && !@resource.valid_for_authentication? { valid_password }) || !valid_password
|
27
27
|
return render_create_error_bad_credentials
|
28
28
|
end
|
29
|
-
@
|
29
|
+
@token = @resource.create_token
|
30
30
|
@resource.save
|
31
31
|
|
32
32
|
sign_in(:user, @resource, store: false, bypass: false)
|
@@ -48,11 +48,11 @@ module DeviseTokenAuth
|
|
48
48
|
def destroy
|
49
49
|
# remove auth instance variables so that after_action does not run
|
50
50
|
user = remove_instance_variable(:@resource) if @resource
|
51
|
-
|
52
|
-
|
51
|
+
client = @token.client
|
52
|
+
@token.clear!
|
53
53
|
|
54
|
-
if user &&
|
55
|
-
user.tokens.delete(
|
54
|
+
if user && client && user.tokens[client]
|
55
|
+
user.tokens.delete(client)
|
56
56
|
user.save!
|
57
57
|
|
58
58
|
yield user if block_given?
|
@@ -35,13 +35,13 @@ module DeviseTokenAuth
|
|
35
35
|
@resource = resource_class.unlock_access_by_token(params[:unlock_token])
|
36
36
|
|
37
37
|
if @resource.persisted?
|
38
|
-
|
38
|
+
token = @resource.create_token
|
39
39
|
@resource.save!
|
40
40
|
yield @resource if block_given?
|
41
41
|
|
42
42
|
redirect_header_options = { unlock: true }
|
43
|
-
redirect_headers = build_redirect_headers(token,
|
44
|
-
|
43
|
+
redirect_headers = build_redirect_headers(token.token,
|
44
|
+
token.client,
|
45
45
|
redirect_header_options)
|
46
46
|
redirect_to(@resource.build_auth_url(after_unlock_path_for(@resource),
|
47
47
|
redirect_headers))
|
@@ -2,11 +2,7 @@ module DeviseTokenAuth::Concerns::ActiveRecordSupport
|
|
2
2
|
extend ActiveSupport::Concern
|
3
3
|
|
4
4
|
included do
|
5
|
-
serialize :tokens,
|
6
|
-
|
7
|
-
# can't set default on text fields in mysql, simulate here instead.
|
8
|
-
after_save :set_empty_token_hash
|
9
|
-
after_initialize :set_empty_token_hash
|
5
|
+
serialize :tokens, DeviseTokenAuth::Concerns::TokensSerialization
|
10
6
|
end
|
11
7
|
|
12
8
|
class_methods do
|
@@ -14,21 +10,5 @@ module DeviseTokenAuth::Concerns::ActiveRecordSupport
|
|
14
10
|
def dta_find_by(attrs = {})
|
15
11
|
find_by(attrs)
|
16
12
|
end
|
17
|
-
|
18
|
-
protected
|
19
|
-
|
20
|
-
def tokens_has_json_column_type?
|
21
|
-
database_exists? && table_exists? && columns_hash['tokens'] && columns_hash['tokens'].type.in?([:json, :jsonb])
|
22
|
-
end
|
23
|
-
|
24
|
-
def database_exists?
|
25
|
-
ActiveRecord::Base.connection_pool.with_connection { |con| con.active? } rescue false
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
protected
|
30
|
-
|
31
|
-
def set_empty_token_hash
|
32
|
-
self.tokens ||= {} if has_attribute?(:tokens)
|
33
13
|
end
|
34
14
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module DeviseTokenAuth::Concerns::ConfirmableSupport
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
# Override standard devise `postpone_email_change?` method
|
6
|
+
# for not to use `will_save_change_to_email?` & `email_changed?` methods.
|
7
|
+
def postpone_email_change?
|
8
|
+
postpone = self.class.reconfirmable &&
|
9
|
+
email_value_in_database != email &&
|
10
|
+
!@bypass_confirmation_postpone &&
|
11
|
+
self.email.present? &&
|
12
|
+
(!@skip_reconfirmation_in_callback || !email_value_in_database.nil?)
|
13
|
+
@bypass_confirmation_postpone = false
|
14
|
+
postpone
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
protected
|
19
|
+
|
20
|
+
def email_value_in_database
|
21
|
+
rails51 = Rails.gem_version >= Gem::Version.new("5.1.x")
|
22
|
+
if rails51 && respond_to?(:email_in_database)
|
23
|
+
email_in_database
|
24
|
+
else
|
25
|
+
email_was
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module DeviseTokenAuth::Concerns::TokensSerialization
|
2
|
+
extend self
|
3
|
+
# Serialization hash to json
|
4
|
+
def dump(object)
|
5
|
+
JSON.generate(object && object.transform_values do |token|
|
6
|
+
serialize_updated_at(token).compact
|
7
|
+
end.compact)
|
8
|
+
end
|
9
|
+
|
10
|
+
# Deserialization json to hash
|
11
|
+
def load(json)
|
12
|
+
case json
|
13
|
+
when String
|
14
|
+
JSON.parse(json)
|
15
|
+
when NilClass
|
16
|
+
{}
|
17
|
+
else
|
18
|
+
json
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def serialize_updated_at(token)
|
25
|
+
updated_at_key = ['updated_at', :updated_at].find(&token.method(:[]))
|
26
|
+
|
27
|
+
return token unless token[updated_at_key].respond_to?(:iso8601)
|
28
|
+
|
29
|
+
token.merge updated_at_key => token[updated_at_key].iso8601
|
30
|
+
end
|
31
|
+
end
|
@@ -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] ||=
|
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
|
@@ -46,6 +44,10 @@ module DeviseTokenAuth::Concerns::User
|
|
46
44
|
def email_changed?; false; end
|
47
45
|
def will_save_change_to_email?; false; end
|
48
46
|
|
47
|
+
if DeviseTokenAuth.send_confirmation_email && devise_modules.include?(:confirmable)
|
48
|
+
include DeviseTokenAuth::Concerns::ConfirmableSupport
|
49
|
+
end
|
50
|
+
|
49
51
|
def password_required?
|
50
52
|
return false unless provider == 'email'
|
51
53
|
super
|
@@ -86,27 +88,25 @@ module DeviseTokenAuth::Concerns::User
|
|
86
88
|
send_devise_notification(:unlock_instructions, raw, opts)
|
87
89
|
raw
|
88
90
|
end
|
89
|
-
end
|
90
91
|
|
91
|
-
|
92
|
-
|
93
|
-
token ||= SecureRandom.urlsafe_base64(nil, false)
|
94
|
-
expiry ||= (Time.zone.now + token_lifespan).to_i
|
92
|
+
def create_token(client: nil, lifespan: nil, cost: nil, **token_extras)
|
93
|
+
token = DeviseTokenAuth::TokenFactory.create(client: client, lifespan: lifespan, cost: cost)
|
95
94
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
95
|
+
tokens[token.client] = {
|
96
|
+
token: token.token_hash,
|
97
|
+
expiry: token.expiry
|
98
|
+
}.merge!(token_extras)
|
100
99
|
|
101
|
-
|
100
|
+
clean_old_tokens
|
102
101
|
|
103
|
-
|
102
|
+
token
|
103
|
+
end
|
104
104
|
end
|
105
105
|
|
106
|
-
def valid_token?(token,
|
107
|
-
return false unless tokens[
|
108
|
-
return true if token_is_current?(token,
|
109
|
-
return true if token_can_be_reused?(token,
|
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)
|
110
110
|
|
111
111
|
# return false if none of the above conditions are met
|
112
112
|
false
|
@@ -116,10 +116,10 @@ module DeviseTokenAuth::Concerns::User
|
|
116
116
|
# can be passed on from the client
|
117
117
|
def send_confirmation_notification?; false; end
|
118
118
|
|
119
|
-
def token_is_current?(token,
|
119
|
+
def token_is_current?(token, client)
|
120
120
|
# ghetto HashWithIndifferentAccess
|
121
|
-
expiry = tokens[
|
122
|
-
token_hash = tokens[
|
121
|
+
expiry = tokens[client]['expiry'] || tokens[client][:expiry]
|
122
|
+
token_hash = tokens[client]['token'] || tokens[client][:token]
|
123
123
|
|
124
124
|
return true if (
|
125
125
|
# ensure that expiry and token are set
|
@@ -134,53 +134,52 @@ module DeviseTokenAuth::Concerns::User
|
|
134
134
|
end
|
135
135
|
|
136
136
|
# allow batch requests to use the previous token
|
137
|
-
def token_can_be_reused?(token,
|
137
|
+
def token_can_be_reused?(token, client)
|
138
138
|
# ghetto HashWithIndifferentAccess
|
139
|
-
updated_at = tokens[
|
140
|
-
|
139
|
+
updated_at = tokens[client]['updated_at'] || tokens[client][:updated_at]
|
140
|
+
last_token_hash = tokens[client]['last_token'] || tokens[client][:last_token]
|
141
141
|
|
142
142
|
return true if (
|
143
143
|
# ensure that the last token and its creation time exist
|
144
|
-
updated_at &&
|
144
|
+
updated_at && last_token_hash &&
|
145
145
|
|
146
146
|
# ensure that previous token falls within the batch buffer throttle time of the last request
|
147
147
|
updated_at.to_time > Time.zone.now - DeviseTokenAuth.batch_request_buffer_throttle &&
|
148
148
|
|
149
149
|
# ensure that the token is valid
|
150
|
-
::
|
150
|
+
DeviseTokenAuth::TokenFactory.token_hash_is_token?(last_token_hash, token)
|
151
151
|
)
|
152
152
|
end
|
153
153
|
|
154
154
|
# update user's auth token (should happen on each request)
|
155
|
-
def create_new_auth_token(
|
155
|
+
def create_new_auth_token(client = nil)
|
156
156
|
now = Time.zone.now
|
157
157
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
last_token: tokens.fetch(client_id, {})['token'],
|
158
|
+
token = create_token(
|
159
|
+
client: client,
|
160
|
+
last_token: tokens.fetch(client, {})['token'],
|
162
161
|
updated_at: now
|
163
162
|
)
|
164
163
|
|
165
|
-
update_auth_header(token,
|
164
|
+
update_auth_header(token.token, token.client)
|
166
165
|
end
|
167
166
|
|
168
|
-
def build_auth_header(token,
|
167
|
+
def build_auth_header(token, client = 'default')
|
169
168
|
# client may use expiry to prevent validation request if expired
|
170
169
|
# must be cast as string or headers will break
|
171
|
-
expiry = tokens[
|
170
|
+
expiry = tokens[client]['expiry'] || tokens[client][:expiry]
|
172
171
|
|
173
172
|
{
|
174
173
|
DeviseTokenAuth.headers_names[:"access-token"] => token,
|
175
174
|
DeviseTokenAuth.headers_names[:"token-type"] => 'Bearer',
|
176
|
-
DeviseTokenAuth.headers_names[:"client"] =>
|
175
|
+
DeviseTokenAuth.headers_names[:"client"] => client,
|
177
176
|
DeviseTokenAuth.headers_names[:"expiry"] => expiry.to_s,
|
178
177
|
DeviseTokenAuth.headers_names[:"uid"] => uid
|
179
178
|
}
|
180
179
|
end
|
181
180
|
|
182
|
-
def update_auth_header(token,
|
183
|
-
headers = build_auth_header(token,
|
181
|
+
def update_auth_header(token, client = 'default')
|
182
|
+
headers = build_auth_header(token, client)
|
184
183
|
clean_old_tokens
|
185
184
|
save!
|
186
185
|
|
@@ -194,9 +193,9 @@ module DeviseTokenAuth::Concerns::User
|
|
194
193
|
DeviseTokenAuth::Url.generate(base_url, args)
|
195
194
|
end
|
196
195
|
|
197
|
-
def extend_batch_buffer(token,
|
198
|
-
tokens[
|
199
|
-
update_auth_header(token,
|
196
|
+
def extend_batch_buffer(token, client)
|
197
|
+
tokens[client]['updated_at'] = Time.zone.now
|
198
|
+
update_auth_header(token, client)
|
200
199
|
end
|
201
200
|
|
202
201
|
def confirmed?
|
@@ -207,10 +206,6 @@ module DeviseTokenAuth::Concerns::User
|
|
207
206
|
as_json(except: %i[tokens created_at updated_at])
|
208
207
|
end
|
209
208
|
|
210
|
-
def token_lifespan
|
211
|
-
DeviseTokenAuth.token_lifespan
|
212
|
-
end
|
213
|
-
|
214
209
|
protected
|
215
210
|
|
216
211
|
def destroy_expired_tokens
|
@@ -223,11 +218,11 @@ module DeviseTokenAuth::Concerns::User
|
|
223
218
|
end
|
224
219
|
|
225
220
|
def should_remove_tokens_after_password_reset?
|
226
|
-
if Rails::VERSION::MAJOR <= 5
|
221
|
+
if Rails::VERSION::MAJOR <= 5 ||defined?('Mongoid')
|
227
222
|
encrypted_password_changed? &&
|
228
223
|
DeviseTokenAuth.remove_tokens_after_password_reset
|
229
224
|
else
|
230
|
-
|
225
|
+
saved_change_to_attribute?(:encrypted_password) &&
|
231
226
|
DeviseTokenAuth.remove_tokens_after_password_reset
|
232
227
|
end
|
233
228
|
end
|
@@ -236,8 +231,8 @@ module DeviseTokenAuth::Concerns::User
|
|
236
231
|
return unless should_remove_tokens_after_password_reset?
|
237
232
|
|
238
233
|
if tokens.present? && tokens.many?
|
239
|
-
|
240
|
-
self.tokens = {
|
234
|
+
client, token_data = tokens.max_by { |cid, v| v[:expiry] || v['expiry'] }
|
235
|
+
self.tokens = { client => token_data }
|
241
236
|
end
|
242
237
|
end
|
243
238
|
|
@@ -5,11 +5,11 @@ module DeviseTokenAuth::Concerns::UserOmniauthCallbacks
|
|
5
5
|
|
6
6
|
included do
|
7
7
|
validates :email, presence: true,if: :email_provider?
|
8
|
-
validates :email,
|
8
|
+
validates :email, :devise_token_auth_email => true, allow_nil: true, allow_blank: true, if: :email_provider?
|
9
9
|
validates_presence_of :uid, unless: :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: :email_provider?
|
13
13
|
|
14
14
|
# keep uid in sync with email
|
15
15
|
before_save :sync_uid
|
@@ -23,6 +23,9 @@ module DeviseTokenAuth::Concerns::UserOmniauthCallbacks
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def sync_uid
|
26
|
+
if devise_modules.include?(:confirmable) && !@bypass_confirmation_postpone
|
27
|
+
return if postpone_email_change?
|
28
|
+
end
|
26
29
|
self.uid = email if email_provider?
|
27
30
|
end
|
28
31
|
end
|
data/app/validators/{devise_token_auth/email_validator.rb → devise_token_auth_email_validator.rb}
RENAMED
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
class
|
3
|
+
class DeviseTokenAuthEmailValidator < ActiveModel::EachValidator
|
4
4
|
def validate_each(record, attribute, value)
|
5
5
|
unless value =~ /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
|
6
|
-
record.errors
|
6
|
+
record.errors.add(attribute, email_invalid_message)
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
data/config/locales/da-DK.yml
CHANGED
@@ -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."
|
data/config/locales/de.yml
CHANGED
@@ -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."
|
data/config/locales/en.yml
CHANGED
@@ -14,6 +14,8 @@ 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."
|
@@ -27,6 +29,11 @@ en:
|
|
27
29
|
missing_email: "You must provide an email address."
|
28
30
|
sended: "An email has been sent to '%{email}' containing instructions for unlocking your account."
|
29
31
|
user_not_found: "Unable to find user with email '%{email}'."
|
32
|
+
confirmations:
|
33
|
+
sended: "An email has been sent to '%{email}' containing instructions for confirming your account."
|
34
|
+
user_not_found: "Unable to find user with email '%{email}'."
|
35
|
+
missing_email: "You must provide an email address."
|
36
|
+
|
30
37
|
errors:
|
31
38
|
messages:
|
32
39
|
validate_sign_up_params: "Please submit proper sign up data in request body."
|