devise_invitable 1.7.4 → 1.7.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.

Potentially problematic release.


This version of devise_invitable might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: a5b47a00992074a2cb6a0ae940340430bafdc284
4
- data.tar.gz: 9348350b9aa008acd22e87b0bd8bf881ec09e190
2
+ SHA256:
3
+ metadata.gz: 51e6d03ee4dd325ebd51b67efc8efb5916b30031842c5bd327f6597bdc149b96
4
+ data.tar.gz: 5fa1f5d1470086846959e4cf20a4d1161db9bd9a6030f82de8941e62db2bc157
5
5
  SHA512:
6
- metadata.gz: b7739cf3d0121a6cbd492eabbd6d7ff9c5d2e1cc4016fcc9dae654be285569a034cc881d8672bc6feec407f2b24c85fad98b281a2b79d84fc1eb9986320580d9
7
- data.tar.gz: 95e436f92ccc7c8828121fc4c7c4ac65d5808bfccb19da4463419939ce48ca6206d13fdb01cc99f47788340731c24f538d0cbfb4a14b954eb6e043350e0b3b18
6
+ metadata.gz: 2f522400741c8c5668a51ec81864739d8cc4d295912e58f7b060b2532f3b1110290db2a0b4201d0522baa163b485c6ba53f225128d9b4288007f428e2ab0918b
7
+ data.tar.gz: fe2b630bb65a1e30a939cd2c3b0cf2a6b86488e2acc728792935fdf358e73c414c3e5a06a82c8ce7a003e10c7614251ba085cc4b797ddfd9480da1b28a28cbf1
@@ -1,22 +1,41 @@
1
- = 1.7.2
1
+ ## 1.7.5
2
+ - Add add_taken_error ([#768](https://github.com/scambra/devise_invitable/pull/768))
3
+ - Add invitation_taken? ([#769](https://github.com/scambra/devise_invitable/pull/769))
4
+ - Rollback invitation_token and invitation_accepted_at if saving failed ([#758](https://github.com/scambra/devise_invitable/pull/758))
5
+ - Don't overwrite confirmed_at ([#761](https://github.com/scambra/devise_invitable/pull/761))
6
+ - Check model responds to confirmed_at= ([#756](https://github.com/scambra/devise_invitable/pull/756))
7
+ - Cleanup mailer views ([#753](https://github.com/scambra/devise_invitable/pull/753))
8
+
9
+ ## 1.7.4
10
+ - Fix invitation_period_valid? with no timestamp ([#743](https://github.com/scambra/devise_invitable/pull/743))
11
+ - fix for ActionController::UnfilteredParameters error on rails 5.2 ([commit](https://github.com/scambra/devise_invitable/commit/481c6b019a41ed913514464e5d5637d7bbf0618b))
12
+
13
+ ## 1.7.3
14
+ - Fix `after_{invite,accept}_path_for` ([#737](https://github.com/scambra/devise_invitable/pull/737))
15
+ - Hide invitable attributes from `#inspect` ([#736](https://github.com/scambra/devise_invitable/pull/736))
16
+ - Generate migration template with version for rails >= 5 ([commit](https://github.com/scambra/devise_invitable/commit/3c44886964a8b3f44ad39c7b0aedd93db45b5815))
17
+ - Set `@accepting_invitation` to false after accepting ([#710](https://github.com/scambra/devise_invitable/pull/710))
18
+ - Override `send_password_change_notification` to handle accepting invitation ([#718](https://github.com/scambra/devise_invitable/pull/718))
19
+
20
+ ## 1.7.2
2
21
  - Sign out before accepting the invitation if the user logged in
3
22
 
4
- = 1.7.1
23
+ ## 1.7.1
5
24
  - Allow to set invited_by_* options on model
6
25
  - created_by_invite scope and test method checks invitation_created_at, because invitation_sent_at can be nil if skip_invitation is used
7
26
 
8
- = 1.7.0
27
+ ## 1.7.0
9
28
 
10
29
  - Drop devise < 4 support
11
30
  - Fix tests for devise 4.2
12
31
 
13
- = 1.6.1
32
+ ## 1.6.1
14
33
 
15
34
  - Support 2 arguments on after_invite_path_for, inviter and invitee
16
35
  - Support mongoid 6.0 (use :optional on invited_by relation)
17
36
  - Support devise 4.1
18
37
 
19
- = 1.6.0
38
+ ## 1.6.0
20
39
 
21
40
  - Support devise 4.0 and rails 5.0
22
41
  - Add before/after invitation_created callbacks
@@ -25,38 +44,38 @@
25
44
  - Ruby 1.9 not supported anymore
26
45
  - Adds :require_password_on_accepting config option, and ensure invitation is not accepted if password is required and removed from form
27
46
 
28
- = 1.5.5
47
+ ## 1.5.5
29
48
 
30
49
  - Add optional options hash to invite! methods, they will be used for send_devise_notification call
31
50
 
32
- = 1.5.4
51
+ ## 1.5.4
33
52
 
34
53
  - Ensure that all invited user passwords conform to a format
35
54
  - Call set_minimum_password_length (if exists) on accept invitation as devise does
36
55
  - Controllers inheriting from Devise::InvitationsController will now use 'devise.invitations' translations
37
- when using Devise >= 3.5. See https://github.com/plataformatec/devise/pull/3407 for more details.
56
+ when using Devise >## 3.5. See https://github.com/plataformatec/devise/pull/3407 for more details.
38
57
  - Add invitation due date to mailer
39
58
 
40
- = 1.5.3
59
+ ## 1.5.3
41
60
 
42
61
  - Fix #585, avoid generating new password if there already is a encrypted one
43
62
  - Give error if trying to register with a registered email
44
63
 
45
- = 1.5.2
64
+ ## 1.5.2
46
65
 
47
66
  - Fix #571, accept invitation when password changes only if reset_password_token was present
48
67
  - Add support for setting invited_by foreign key
49
68
  - Set random initial password for invited users
50
69
  - Don't override password while User.invite!
51
70
 
52
- = 1.5.1
71
+ ## 1.5.1
53
72
 
54
73
  - Fix #562 Avoid using after_password_reset
55
74
  - Fix #564
56
75
 
57
76
  Compare: https://github.com/scambra/devise_invitable/compare/v1.5.0...v1.5.1
58
77
 
59
- = 1.5.0
78
+ ## 1.5.0
60
79
 
61
80
  Override valid_password? and unauthenticated_message instead of active_for_authentication? and inactive_message, active_for_authentication? doesn't work for default behavior of invited users without password
62
81
 
@@ -67,7 +86,7 @@ Override valid_password? and unauthenticated_message instead of active_for_authe
67
86
 
68
87
  Compare: https://github.com/scambra/devise_invitable/compare/v1.4.2...v1.5.0
69
88
 
70
- = 1.4.2
89
+ ## 1.4.2
71
90
 
72
91
  - Add option to allow controlling of auto sign in functionality for security
73
92
  - Add intermediate method in active_for_authentication? for more flexibility
@@ -77,7 +96,7 @@ Compare: https://github.com/scambra/devise_invitable/compare/v1.4.2...v1.5.0
77
96
 
78
97
  Compare: https://github.com/scambra/devise_invitable/compare/v1.4.1...v1.4.2
79
98
 
80
- = 1.4.1
99
+ ## 1.4.1
81
100
 
82
101
  - Begin testing against devise 3.4
83
102
  - Use current_inviter to get redirect path after invite
@@ -85,14 +104,14 @@ Compare: https://github.com/scambra/devise_invitable/compare/v1.4.1...v1.4.2
85
104
 
86
105
  Compare: https://github.com/scambra/devise_invitable/compare/v1.4.0...v1.4.1
87
106
 
88
- = 1.4.0
107
+ ## 1.4.0
89
108
 
90
109
  Override active_for_authentication? and inactive_message instead of valid_password?
91
110
  To use counter_cache, invited_by_counter_cache must be set, no more checking of invitations_count to enable counter cache
92
111
 
93
112
  Compare: https://github.com/scambra/devise_invitable/compare/v1.3.6...v1.4.0
94
113
 
95
- = 1.3.6
114
+ ## 1.3.6
96
115
 
97
116
  - Regenerate invitation token each time even if "skip_invitation" was true
98
117
  - Add passing a block to instance #invite! method
@@ -100,14 +119,14 @@ Compare: https://github.com/scambra/devise_invitable/compare/v1.3.6...v1.4.0
100
119
 
101
120
  Compare: https://github.com/scambra/devise_invitable/compare/v1.3.5...v1.3.6
102
121
 
103
- = 1.3.5
122
+ ## 1.3.5
104
123
 
105
124
  No notes yet, contributions welcome.
106
125
 
107
- = 1.3.0
126
+ ## 1.3.0
108
127
 
109
128
  Now devise 3.1 compatible, @token must be used instead of @resource.invitation_token in mail views
110
129
 
111
- = 1.2.0
130
+ ## 1.2.0
112
131
 
113
132
  Add invitation_created_at column which is set when invitation is created even when sending is skipped. This new field is used to check invitation period valid
@@ -248,7 +248,7 @@ the value is temporarily available when you invite a user and will be decrypted
248
248
 
249
249
  When <tt>skip_invitation</tt> is used, you must also then set the <tt>invitation_sent_at</tt> field when the user is sent their
250
250
  token. Failure to do so will yield <tt>Invalid invitation token</tt> error when the user attempts to accept the invite.
251
- You can set it like so:
251
+ You can set column, or call <tt>deliver_invitation</tt> to sent invitation and set column:
252
252
 
253
253
  user.deliver_invitation
254
254
 
@@ -321,9 +321,9 @@ A pair of scopes to find those users that have accepted, and those that have not
321
321
  Since the invitations controller take care of all the creation/acceptation of an invitation, in most cases you wouldn't call the <tt>invite!</tt> and <tt>accept_invitation!</tt> methods directly.
322
322
  Instead, in your views, put a link to <tt>new_user_invitation_path</tt> or <tt>new_invitation_path(:user)</tt> or even <tt>/users/invitation/new</tt> to prepare and send an invitation (to a user in this example).
323
323
 
324
- After an invitation is created and sent, the inviter will be redirected to after_invite_path_for(inviter, invitee), which is stored path or the same path as after_sign_in_path_for by default.
324
+ After an invitation is created and sent, the inviter will be redirected to after_invite_path_for(inviter, invitee), which is the same path as signed_in_root_path by default.
325
325
 
326
- After an invitation is accepted, the invitee will be redirected to after_accept_path_for(resource), which is the same path as after_sign_in_path_for by default. If you want to override the path, override invitations controller and define after_accept_path_for method. This is useful in the common case that a user is invited to a specific location in your application. More on {Devise's README}[https://github.com/plataformatec/devise], "Controller filters and helpers" section.
326
+ After an invitation is accepted, the invitee will be redirected to after_accept_path_for(resource), which is the same path as signed_in_root_path by default. If you want to override the path, override invitations controller and define after_accept_path_for method. This is useful in the common case that a user is invited to a specific location in your application. More on {Devise's README}[https://github.com/plataformatec/devise], "Controller filters and helpers" section.
327
327
 
328
328
  The invitation email includes a link to accept the invitation that looks like this: <tt>/users/invitation/accept?invitation_token=abcd123</tt>. When clicked, the invited must set a password in order to accept its invitation. Note that if the invitation_token is not present or not valid, the invited is redirected to after_sign_out_path_for(resource_name).
329
329
 
@@ -37,7 +37,6 @@ class Devise::InvitationsController < DeviseController
37
37
 
38
38
  # GET /resource/invitation/accept?invitation_token=abcdef
39
39
  def edit
40
- sign_out send("current_#{resource_name}") if send("#{resource_name}_signed_in?")
41
40
  set_minimum_password_length
42
41
  resource.invitation_token = params[:invitation_token]
43
42
  render :edit
@@ -8,4 +8,4 @@
8
8
  <p><%= t("devise.mailer.invitation_instructions.accept_until", due_date: l(@resource.invitation_due_at, format: :'devise.mailer.invitation_instructions.accept_until_format')) %></p>
9
9
  <% end %>
10
10
 
11
- <p><%= t("devise.mailer.invitation_instructions.ignore").html_safe %></p>
11
+ <p><%= t("devise.mailer.invitation_instructions.ignore") %></p>
@@ -8,4 +8,4 @@
8
8
  <%= t("devise.mailer.invitation_instructions.accept_until", due_date: l(@resource.invitation_due_at, format: :'devise.mailer.invitation_instructions.accept_until_format')) %>
9
9
  <% end %>
10
10
 
11
- <%= strip_tags t("devise.mailer.invitation_instructions.ignore") %>
11
+ <%= t("devise.mailer.invitation_instructions.ignore") %>
@@ -22,7 +22,7 @@ en:
22
22
  someone_invited_you: "Someone has invited you to %{url}, you can accept it through the link below."
23
23
  accept: "Accept invitation"
24
24
  accept_until: "This invitation will be due in %{due_date}."
25
- ignore: "If you don't want to accept the invitation, please ignore this email.<br />\nYour account won't be created until you access the link above and set your password."
25
+ ignore: "If you don't want to accept the invitation, please ignore this email. Your account won't be created until you access the link above and set your password."
26
26
  time:
27
27
  formats:
28
28
  devise:
@@ -95,12 +95,21 @@ module Devise
95
95
  @accepting_invitation = true
96
96
  run_callbacks :invitation_accepted do
97
97
  self.accept_invitation
98
- self.confirmed_at = self.invitation_accepted_at if self.respond_to?(:confirmed_at)
98
+ self.confirmed_at ||= self.invitation_accepted_at if self.respond_to?(:confirmed_at=)
99
99
  self.save
100
- end.tap { @accepting_invitation = false }
100
+ end.tap do |saved|
101
+ self.rollback_accepted_invitation if !saved
102
+ @accepting_invitation = false
103
+ end
101
104
  end
102
105
  end
103
106
 
107
+ def rollback_accepted_invitation
108
+ self.invitation_token = self.invitation_token_was
109
+ self.invitation_accepted_at = nil
110
+ self.confirmed_at = nil if self.respond_to?(:confirmed_at=)
111
+ end
112
+
104
113
  # Verify wheather a user is created by invitation, irrespective to invitation status
105
114
  def created_by_invite?
106
115
  invitation_created_at.present?
@@ -218,6 +227,14 @@ module Devise
218
227
  time + self.class.invite_for
219
228
  end
220
229
 
230
+ def add_taken_error(key)
231
+ errors.add(key, :taken)
232
+ end
233
+
234
+ def invitation_taken?
235
+ !invited_to_sign_up?
236
+ end
237
+
221
238
  protected
222
239
 
223
240
  def block_from_invitation?
@@ -300,9 +317,9 @@ module Devise
300
317
  invitable.valid? if self.validate_on_invite
301
318
  if invitable.new_record?
302
319
  invitable.clear_errors_on_valid_keys if !self.validate_on_invite
303
- elsif !invitable.invited_to_sign_up? || !self.resend_invitation
320
+ elsif invitable.invitation_taken? || !self.resend_invitation
304
321
  invite_key_array.each do |key|
305
- invitable.errors.add(key, :taken)
322
+ invitable.add_taken_error(key)
306
323
  end
307
324
  end
308
325
 
@@ -1,3 +1,3 @@
1
1
  module DeviseInvitable
2
- VERSION = '1.7.4'
2
+ VERSION = '1.7.5'
3
3
  end
@@ -228,9 +228,13 @@ class InvitableTest < ActiveSupport::TestCase
228
228
  assert user.invitation_token.present?
229
229
  assert_nil user.invitation_accepted_at
230
230
  user.accept_invitation!
231
+ assert_nil user.invitation_token
232
+ assert user.invitation_accepted_at.present?
233
+ assert user.invitation_accepted?
231
234
  user.reload
232
235
  assert_nil user.invitation_token
233
236
  assert user.invitation_accepted_at.present?
237
+ assert user.invitation_accepted?
234
238
  end
235
239
 
236
240
  test 'should not clear invitation token or set accepted_at if record is invalid' do
@@ -245,6 +249,17 @@ class InvitableTest < ActiveSupport::TestCase
245
249
  assert_nil user.invitation_accepted_at
246
250
  end
247
251
 
252
+ test 'should not require reloading if invalid' do
253
+ user = User.invite!(:email => "valid@email.com")
254
+ assert user.invitation_token.present?
255
+ assert_nil user.invitation_accepted_at
256
+ user.attributes = { :password => '123456789', :password_confirmation => '987654321' }
257
+ user.accept_invitation!
258
+ assert user.invitation_token.present?
259
+ assert_nil user.invitation_accepted_at
260
+ assert !user.invitation_accepted?
261
+ end
262
+
248
263
  test 'should clear invitation token while resetting the password' do
249
264
  user = User.invite!(:email => "valid@email.com")
250
265
  assert user.invited_to_sign_up?
@@ -1,4 +1,8 @@
1
1
  ActiveRecord::Migration.verbose = false
2
2
  ActiveRecord::Base.logger = Logger.new(nil)
3
3
 
4
- ActiveRecord::Migrator.migrate(File.expand_path("../../rails_app/db/migrate/", __FILE__))
4
+ if defined? ActiveRecord::MigrationContext # rails >= 5.2
5
+ ActiveRecord::MigrationContext.new(File.expand_path("../../rails_app/db/migrate/", __FILE__)).migrate
6
+ else
7
+ ActiveRecord::Migrator.migrate(File.expand_path("../../rails_app/db/migrate/", __FILE__))
8
+ end
@@ -23,6 +23,7 @@ module RailsApp
23
23
  config.action_mailer.default_url_options = { :host => "localhost:3000" }
24
24
  if DEVISE_ORM == :active_record && Rails.version.start_with?('5')
25
25
  config.active_record.maintain_test_schema = false
26
+ config.active_record.sqlite3.represent_boolean_as_integer = true if config.active_record.sqlite3
26
27
  end
27
28
  end
28
29
  end
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: 1.7.4
4
+ version: 1.7.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergio Cambra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-09 00:00:00.000000000 Z
11
+ date: 2018-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -60,7 +60,7 @@ executables: []
60
60
  extensions: []
61
61
  extra_rdoc_files: []
62
62
  files:
63
- - CHANGELOG
63
+ - CHANGELOG.md
64
64
  - LICENSE
65
65
  - README.rdoc
66
66
  - app/controllers/devise/invitations_controller.rb
@@ -164,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
164
  version: 1.3.6
165
165
  requirements: []
166
166
  rubyforge_project:
167
- rubygems_version: 2.6.10
167
+ rubygems_version: 2.7.7
168
168
  signing_key:
169
169
  specification_version: 4
170
170
  summary: An invitation strategy for Devise