devise_invitable 2.0.8 → 2.0.10
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/CHANGELOG.md +5 -0
- data/README.md +696 -0
- data/config/locales/fr.yml +6 -9
- data/config/locales/id.yml +31 -0
- data/config/locales/zh-CN.yml +31 -0
- data/config/locales/zh-TW.yml +15 -12
- data/lib/devise_invitable/models.rb +7 -7
- data/lib/devise_invitable/version.rb +1 -1
- data/test/models/invitable_test.rb +53 -0
- data/test/orm/active_record.rb +9 -9
- data/test/test_helper.rb +3 -1
- metadata +7 -5
- data/README.rdoc +0 -496
data/config/locales/fr.yml
CHANGED
@@ -4,20 +4,17 @@ fr:
|
|
4
4
|
invited: "Vous avez une invitation en attente, acceptez-la pour terminer la création de votre compte."
|
5
5
|
invitations:
|
6
6
|
send_instructions: "Un e-mail d'invitation a été envoyé à %{email}."
|
7
|
-
invitation_token_invalid: "Le jeton d'invitation fourni n'est pas valide!"
|
7
|
+
invitation_token_invalid: "Le jeton d'invitation fourni n'est pas valide !"
|
8
8
|
updated: 'Votre mot de passe a été défini avec succès. Vous êtes maintenant connecté.'
|
9
9
|
updated_not_active: "Votre mot de passe a été défini avec succès."
|
10
|
-
no_invitations_remaining: "Il n'y a plus d'invitations restantes"
|
10
|
+
no_invitations_remaining: "Il n'y a plus d'invitations restantes."
|
11
11
|
invitation_removed: 'Votre invitation a été supprimée.'
|
12
12
|
new:
|
13
13
|
header: Nouvel utilisateur
|
14
|
-
legend: Envoyer l’invitation
|
15
14
|
submit_button: Envoyer
|
16
15
|
edit:
|
17
|
-
header:
|
18
|
-
submit_button:
|
19
|
-
new_password: Mot de passe
|
20
|
-
new_password_confirmation: Confirmation du mot de passe
|
16
|
+
header: Définissez votre mot de passe
|
17
|
+
submit_button: Définir mon mot de passe
|
21
18
|
mailer:
|
22
19
|
invitation_instructions:
|
23
20
|
subject: 'Vous avez reçu une invitation'
|
@@ -25,10 +22,10 @@ fr:
|
|
25
22
|
someone_invited_you: "Vous avez été invité à rejoindre %{url}, vous pouvez accepter cette invitation via le lien ci-dessous."
|
26
23
|
accept: "Accepter l'invitation"
|
27
24
|
accept_until: "Cette invitation sera valable jusqu'au %{due_date}."
|
28
|
-
ignore: "Si vous ne souhaitez pas accepter cette invitation, veuillez ignorer cet e-mail
|
25
|
+
ignore: "Si vous ne souhaitez pas accepter cette invitation, veuillez ignorer cet e-mail. Votre compte ne sera pas créé tant que vous n'aurez pas cliqué sur le lien ci-dessous et défini votre mot de passe."
|
29
26
|
time:
|
30
27
|
formats:
|
31
28
|
devise:
|
32
29
|
mailer:
|
33
30
|
invitation_instructions:
|
34
|
-
accept_until_format: "%
|
31
|
+
accept_until_format: "%d %B %Y à %H:%M"
|
@@ -0,0 +1,31 @@
|
|
1
|
+
id:
|
2
|
+
devise:
|
3
|
+
failure:
|
4
|
+
invited: "Anda memiliki undangan yang tertunda, harap terima undangan tersebut untuk menyelesaikan pembuatan akun Anda."
|
5
|
+
invitations:
|
6
|
+
send_instructions: "Email undangan telah dikirim ke %{email}."
|
7
|
+
invitation_token_invalid: "Token undangan yang diberikan tidak valid!"
|
8
|
+
updated: "Kata sandi Anda telah berhasil diatur. Anda sudah masuk."
|
9
|
+
updated_not_active: "Kata sandi Anda telah berhasil diatur."
|
10
|
+
no_invitations_remaining: "Tidak ada undangan tersisa."
|
11
|
+
invitation_removed: "Undangan Anda telah dihapus."
|
12
|
+
new:
|
13
|
+
header: "Kirim Undangan"
|
14
|
+
submit_button: "Kirim undangan"
|
15
|
+
edit:
|
16
|
+
header: "Atur kata sandi Anda"
|
17
|
+
submit_button: "Atur kata sandi"
|
18
|
+
mailer:
|
19
|
+
invitation_instructions:
|
20
|
+
subject: "Instruksi Undangan"
|
21
|
+
hello: "Halo %{email}"
|
22
|
+
someone_invited_you: "Seseorang telah mengundang Anda ke %{url}. Anda dapat menerima undangan ini melalui tautan di bawah ini."
|
23
|
+
accept: "Terima Undangan"
|
24
|
+
accept_until: "Undangan ini akan berakhir pada %{due_date}."
|
25
|
+
ignore: "Jika Anda tidak ingin menerima undangan ini, silakan abaikan email ini. Akun Anda tidak akan dibuat sampai Anda mengakses tautan di atas dan mengatur kata sandi Anda."
|
26
|
+
time:
|
27
|
+
formats:
|
28
|
+
devise:
|
29
|
+
mailer:
|
30
|
+
invitation_instructions:
|
31
|
+
accept_until_format: "%d %B %Y %H:%M:%S"
|
@@ -0,0 +1,31 @@
|
|
1
|
+
zh-CN:
|
2
|
+
devise:
|
3
|
+
failure:
|
4
|
+
invited: "您有一封待处理的帐号邀请,请接受邀请完成创建您的帐号。"
|
5
|
+
invitations:
|
6
|
+
send_instructions: "邀请电子邮件已发送至 %{email}。"
|
7
|
+
invitation_token_invalid: "所提供的邀请验证无效!"
|
8
|
+
updated: "您的密码已设置成功,。现在您已经登入了。"
|
9
|
+
updated_not_active: "您的密码已设置成功。"
|
10
|
+
no_invitations_remaining: "没有待处理的邀请"
|
11
|
+
invitation_removed: "您的邀请被删除了。"
|
12
|
+
new:
|
13
|
+
header: "发送邀请"
|
14
|
+
submit_button: "发送邀请"
|
15
|
+
edit:
|
16
|
+
header: "设置您的密码"
|
17
|
+
submit_button: "设置密码"
|
18
|
+
mailer:
|
19
|
+
invitation_instructions:
|
20
|
+
subject: "邀请"
|
21
|
+
hello: "%{email} 您好"
|
22
|
+
someone_invited_you: "邀请您加入 %{url},您可以通过以下的网页链接接受邀请,并创设帐号:"
|
23
|
+
accept: "接受邀请"
|
24
|
+
accept_until: "这封邀请将于 %{due_date} 到期。"
|
25
|
+
ignore: "如果您不想接受邀请,请忽略这封电子邮件。只要未选取上述“接受邀请”的链接并且设置密码,您的帐号就不会成立。"
|
26
|
+
time:
|
27
|
+
formats:
|
28
|
+
devise:
|
29
|
+
mailer:
|
30
|
+
invitation_instructions:
|
31
|
+
accept_until_format: "%B %d, %Y %I:%M %p"
|
data/config/locales/zh-TW.yml
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
zh-TW:
|
2
2
|
devise:
|
3
3
|
failure:
|
4
|
-
invited: "
|
4
|
+
invited: "你有一封設立帳號的邀請,請接受邀請來創建你的帳號。"
|
5
5
|
invitations:
|
6
|
-
send_instructions: "邀請已發送至%{email)
|
7
|
-
invitation_token_invalid: "
|
8
|
-
updated: "
|
9
|
-
updated_not_active: "
|
10
|
-
no_invitations_remaining: "
|
11
|
-
invitation_removed: "
|
6
|
+
send_instructions: "邀請已發送至%{email)"
|
7
|
+
invitation_token_invalid: "所提供的邀請驗證無效!"
|
8
|
+
updated: "你的密碼已設置成功,現在你已經登入了。"
|
9
|
+
updated_not_active: "密碼設置成功"
|
10
|
+
no_invitations_remaining: "邀請名額已用盡"
|
11
|
+
invitation_removed: "你的邀請被刪除了"
|
12
12
|
new:
|
13
13
|
header: "發送邀請"
|
14
14
|
submit_button: "發送邀請"
|
@@ -17,12 +17,15 @@ zh-TW:
|
|
17
17
|
submit_button: "設置密碼"
|
18
18
|
mailer:
|
19
19
|
invitation_instructions:
|
20
|
-
subject: "
|
21
|
-
hello: "%{email}
|
22
|
-
someone_invited_you:
|
20
|
+
subject: "邀請"
|
21
|
+
hello: "%{email} 你好,"
|
22
|
+
someone_invited_you: “邀請你加入%{url}。你可以通過以下的網頁連結接受邀請,並創設帳號:"
|
23
23
|
accept: "接受邀請"
|
24
|
-
accept_until: "
|
25
|
-
ignore:
|
24
|
+
accept_until: "這封邀請將於 %{due_date} 到期。"
|
25
|
+
ignore:
|
26
|
+
"如果你不想接受邀請,
|
27
|
+
請忽略這封電子郵件。只要未選取上述“接受邀請”的連結並且設置密碼,你的帳號就不會成立。"
|
28
|
+
|
26
29
|
time:
|
27
30
|
formats:
|
28
31
|
devise:
|
@@ -30,12 +30,12 @@ module Devise
|
|
30
30
|
|
31
31
|
included do
|
32
32
|
include ::DeviseInvitable::Inviter
|
33
|
-
belongs_to_options = if
|
34
|
-
{ class_name:
|
33
|
+
belongs_to_options = if invited_by_class_name
|
34
|
+
{ class_name: invited_by_class_name }
|
35
35
|
else
|
36
36
|
{ polymorphic: true }
|
37
37
|
end
|
38
|
-
if fk =
|
38
|
+
if fk = invited_by_foreign_key
|
39
39
|
belongs_to_options[:foreign_key] = fk
|
40
40
|
end
|
41
41
|
if defined?(ActiveRecord) && defined?(ActiveRecord::Base) && self < ActiveRecord::Base
|
@@ -76,9 +76,9 @@ module Devise
|
|
76
76
|
|
77
77
|
def self.required_fields(klass)
|
78
78
|
fields = [:invitation_token, :invitation_created_at, :invitation_sent_at, :invitation_accepted_at,
|
79
|
-
:invitation_limit,
|
79
|
+
:invitation_limit, klass.invited_by_foreign_key || :invited_by_id, :invited_by_type]
|
80
80
|
fields << :invitations_count if defined?(ActiveRecord) && self < ActiveRecord::Base
|
81
|
-
fields -= [:invited_by_type] if
|
81
|
+
fields -= [:invited_by_type] if klass.invited_by_class_name
|
82
82
|
fields
|
83
83
|
end
|
84
84
|
|
@@ -195,7 +195,7 @@ module Devise
|
|
195
195
|
def clear_reset_password_token
|
196
196
|
reset_password_token_present = reset_password_token.present?
|
197
197
|
super
|
198
|
-
accept_invitation! if reset_password_token_present &&
|
198
|
+
accept_invitation! if reset_password_token_present && valid_invitation?
|
199
199
|
end
|
200
200
|
|
201
201
|
def clear_errors_on_valid_keys
|
@@ -231,7 +231,7 @@ module Devise
|
|
231
231
|
def add_taken_error(key)
|
232
232
|
errors.add(key, :taken)
|
233
233
|
end
|
234
|
-
|
234
|
+
|
235
235
|
def invitation_taken?
|
236
236
|
!invited_to_sign_up?
|
237
237
|
end
|
@@ -279,6 +279,23 @@ class InvitableTest < ActiveSupport::TestCase
|
|
279
279
|
refute_predicate user, :invited_to_sign_up?
|
280
280
|
end
|
281
281
|
|
282
|
+
test 'should not accept expired invitation while resetting the password' do
|
283
|
+
User.stubs(:invite_for).returns(1.day)
|
284
|
+
user = User.invite!(email: 'valid@email.com')
|
285
|
+
assert user.invited_to_sign_up?
|
286
|
+
user.invitation_created_at = Time.now.utc - 2.days
|
287
|
+
token, user.reset_password_token = Devise.token_generator.generate(User, :reset_password_token)
|
288
|
+
user.reset_password_sent_at = Time.now.utc
|
289
|
+
user.save
|
290
|
+
|
291
|
+
assert user.reset_password_token.present?
|
292
|
+
assert user.invitation_token.present?
|
293
|
+
User.reset_password_by_token(reset_password_token: token, password: '123456789', password_confirmation: '123456789')
|
294
|
+
assert_nil user.reload.reset_password_token
|
295
|
+
assert user.reload.invitation_token.present?
|
296
|
+
assert user.reload.invited_to_sign_up?
|
297
|
+
end
|
298
|
+
|
282
299
|
test 'should not accept invitation on failing to reset the password' do
|
283
300
|
user = User.invite!(email: 'valid@email.com')
|
284
301
|
assert user.invited_to_sign_up?
|
@@ -366,6 +383,42 @@ class InvitableTest < ActiveSupport::TestCase
|
|
366
383
|
User.validate_on_invite = validate_on_invite
|
367
384
|
end
|
368
385
|
|
386
|
+
test 'should not validate other attributes when validate_on_invite is disabled (for instance method)' do
|
387
|
+
validate_on_invite = User.validate_on_invite
|
388
|
+
User.validate_on_invite = false
|
389
|
+
user = new_user(email: 'valid@email.com', username: 'a' * 50)
|
390
|
+
user.invite!(nil, validate: false)
|
391
|
+
assert_empty user.errors
|
392
|
+
User.validate_on_invite = validate_on_invite
|
393
|
+
end
|
394
|
+
|
395
|
+
test 'should validate other attributes when validate_on_invite is disabled and validate option is enabled (for instance method)' do
|
396
|
+
validate_on_invite = User.validate_on_invite
|
397
|
+
User.validate_on_invite = false
|
398
|
+
user = new_user(email: 'valid@email.com', username: 'a' * 50)
|
399
|
+
user.invite!(nil, validate: true)
|
400
|
+
refute_empty user.errors[:username]
|
401
|
+
User.validate_on_invite = validate_on_invite
|
402
|
+
end
|
403
|
+
|
404
|
+
test 'should validate other attributes when validate_on_invite is enabled and validate option is disabled (for instance method)' do
|
405
|
+
validate_on_invite = User.validate_on_invite
|
406
|
+
User.validate_on_invite = true
|
407
|
+
user = new_user(email: 'valid@email.com', username: 'a' * 50)
|
408
|
+
user.invite!
|
409
|
+
refute_empty user.errors[:username]
|
410
|
+
User.validate_on_invite = validate_on_invite
|
411
|
+
end
|
412
|
+
|
413
|
+
test 'should validate other attributes when validate_on_invite is enabled and validate option is disabled explicitly (for instance method)' do
|
414
|
+
validate_on_invite = User.validate_on_invite
|
415
|
+
User.validate_on_invite = true
|
416
|
+
user = new_user(email: 'valid@email.com', username: 'a' * 50)
|
417
|
+
user.invite!(nil, validate: false)
|
418
|
+
assert_empty user.errors
|
419
|
+
User.validate_on_invite = validate_on_invite
|
420
|
+
end
|
421
|
+
|
369
422
|
test 'should return a record with errors if user was found by e-mail' do
|
370
423
|
existing_user = User.new(email: 'valid@email.com')
|
371
424
|
existing_user.save(validate: false)
|
data/test/orm/active_record.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
ActiveRecord::Migration.verbose = false
|
2
2
|
ActiveRecord::Base.logger = Logger.new(nil)
|
3
3
|
|
4
|
-
if ActiveRecord::VERSION::MAJOR >=
|
4
|
+
if ActiveRecord::VERSION::MAJOR >= 7
|
5
5
|
ActiveRecord::MigrationContext.new(
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
end
|
6
|
+
File.expand_path('../../rails_app/db/migrate/', __FILE__)
|
7
|
+
).migrate
|
8
|
+
else # rails 6
|
9
|
+
ActiveRecord::MigrationContext.new(
|
10
|
+
File.expand_path('../../rails_app/db/migrate/', __FILE__),
|
11
|
+
ActiveRecord::Base.connection.schema_migration
|
12
|
+
).migrate
|
13
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -13,7 +13,9 @@ ActionMailer::Base.delivery_method = :test
|
|
13
13
|
ActionMailer::Base.perform_deliveries = true
|
14
14
|
ActionMailer::Base.default_url_options[:host] = 'example.com'
|
15
15
|
|
16
|
-
ActiveSupport::Deprecation.silenced
|
16
|
+
if ActiveSupport::Deprecation.respond_to?(:silenced=)
|
17
|
+
ActiveSupport::Deprecation.silenced = true
|
18
|
+
end
|
17
19
|
$VERBOSE = false
|
18
20
|
|
19
21
|
class ActionDispatch::IntegrationTest
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise_invitable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergio Cambra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionmailer
|
@@ -62,7 +62,7 @@ extra_rdoc_files: []
|
|
62
62
|
files:
|
63
63
|
- CHANGELOG.md
|
64
64
|
- LICENSE
|
65
|
-
- README.
|
65
|
+
- README.md
|
66
66
|
- app/controllers/devise/invitations_controller.rb
|
67
67
|
- app/controllers/devise_invitable/registrations_controller.rb
|
68
68
|
- app/views/devise/invitations/edit.html.erb
|
@@ -78,6 +78,7 @@ files:
|
|
78
78
|
- config/locales/et.yml
|
79
79
|
- config/locales/fa.yml
|
80
80
|
- config/locales/fr.yml
|
81
|
+
- config/locales/id.yml
|
81
82
|
- config/locales/it.yml
|
82
83
|
- config/locales/ja.yml
|
83
84
|
- config/locales/ko.yml
|
@@ -90,6 +91,7 @@ files:
|
|
90
91
|
- config/locales/tr.yml
|
91
92
|
- config/locales/ua.yml
|
92
93
|
- config/locales/vi.yml
|
94
|
+
- config/locales/zh-CN.yml
|
93
95
|
- config/locales/zh-HK.yml
|
94
96
|
- config/locales/zh-TW.yml
|
95
97
|
- lib/devise_invitable.rb
|
@@ -172,7 +174,7 @@ metadata: {}
|
|
172
174
|
post_install_message:
|
173
175
|
rdoc_options:
|
174
176
|
- "--main"
|
175
|
-
- README.
|
177
|
+
- README.md
|
176
178
|
- "--charset=UTF-8"
|
177
179
|
require_paths:
|
178
180
|
- lib
|
@@ -187,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
187
189
|
- !ruby/object:Gem::Version
|
188
190
|
version: '0'
|
189
191
|
requirements: []
|
190
|
-
rubygems_version: 3.
|
192
|
+
rubygems_version: 3.5.11
|
191
193
|
signing_key:
|
192
194
|
specification_version: 4
|
193
195
|
summary: An invitation strategy for Devise
|