devise_invitable 1.7.2 → 1.7.3
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 +4 -4
- data/app/controllers/devise/invitations_controller.rb +4 -11
- data/app/views/devise/invitations/edit.html.erb +1 -1
- data/lib/devise_invitable.rb +1 -1
- data/lib/devise_invitable/controllers/helpers.rb +7 -6
- data/lib/devise_invitable/{model.rb → models.rb} +7 -1
- data/lib/devise_invitable/models/authenticatable.rb +11 -0
- data/lib/devise_invitable/version.rb +1 -1
- data/lib/generators/active_record/devise_invitable_generator.rb +7 -1
- data/lib/generators/active_record/templates/migration.rb +1 -1
- data/test/functional/registrations_controller_test.rb +5 -5
- data/test/integration/invitation_test.rb +2 -2
- data/test/models/invitable_test.rb +18 -0
- data/test/rails_app/app/controllers/application_controller.rb +1 -1
- data/test/rails_app/app/controllers/users_controller.rb +1 -1
- data/test/rails_app/app/models/user.rb +1 -1
- data/test/rails_app/db/migrate/20100401102949_create_tables.rb +1 -1
- data/test/test_helper.rb +7 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 120262595eb64c2331645be7ee5b72be56cf69dd
|
4
|
+
data.tar.gz: 9cf5ffa08b34fe9d69e09272c23f92800b0357f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f73d12b8a22bb35067552438a6fa394e150525c54de6e3d25372b0a0d345b4ec74332cdd190075b1b5f4b82b34413115ec1fb650ab83cf20acc3345906daae4
|
7
|
+
data.tar.gz: a24d5a8744f72552413216e8f7947ff58a7be06fcbc2683cd9caaa9fc4a90b4384b4c89f54c2aa9930bf369da289922dbb9b445824de139f685671a9a6e48a1b
|
@@ -1,15 +1,8 @@
|
|
1
1
|
class Devise::InvitationsController < DeviseController
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
prepend_before_action :resource_from_invitation_token, :only => [:edit, :destroy]
|
7
|
-
else
|
8
|
-
prepend_before_filter :authenticate_inviter!, :only => [:new, :create]
|
9
|
-
prepend_before_filter :has_invitations_left?, :only => [:create]
|
10
|
-
prepend_before_filter :require_no_authentication, :only => [:edit, :update, :destroy]
|
11
|
-
prepend_before_filter :resource_from_invitation_token, :only => [:edit, :destroy]
|
12
|
-
end
|
2
|
+
prepend_before_action :authenticate_inviter!, :only => [:new, :create]
|
3
|
+
prepend_before_action :has_invitations_left?, :only => [:create]
|
4
|
+
prepend_before_action :require_no_authentication, :only => [:edit, :update, :destroy]
|
5
|
+
prepend_before_action :resource_from_invitation_token, :only => [:edit, :destroy]
|
13
6
|
|
14
7
|
if respond_to? :helper_method
|
15
8
|
helper_method :after_sign_in_path_for
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
<%= form_for resource, :as => resource_name, :url => invitation_path(resource_name), :html => { :method => :put } do |f| %>
|
4
4
|
<%= devise_error_messages! %>
|
5
|
-
<%= f.hidden_field :invitation_token %>
|
5
|
+
<%= f.hidden_field :invitation_token, readonly: true %>
|
6
6
|
|
7
7
|
<% if f.object.class.require_password_on_accepting %>
|
8
8
|
<p><%= f.label :password %><br />
|
data/lib/devise_invitable.rb
CHANGED
@@ -84,4 +84,4 @@ module Devise
|
|
84
84
|
@@require_password_on_accepting = true
|
85
85
|
end
|
86
86
|
|
87
|
-
Devise.add_module :invitable, :controller => :invitations, :model => 'devise_invitable/
|
87
|
+
Devise.add_module :invitable, :controller => :invitations, :model => 'devise_invitable/models', :route => {:invitation => [nil, :new, :accept]}
|
@@ -3,19 +3,20 @@ module DeviseInvitable::Controllers::Helpers
|
|
3
3
|
|
4
4
|
included do
|
5
5
|
end
|
6
|
-
|
6
|
+
|
7
7
|
def after_invite_path_for(inviter, invitee = nil)
|
8
|
-
|
8
|
+
signed_in_root_path(inviter)
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def after_accept_path_for(resource)
|
12
|
-
|
12
|
+
signed_in_root_path(resource)
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
protected
|
16
|
+
|
16
17
|
def authenticate_inviter!
|
17
18
|
send(:"authenticate_#{resource_name}!", :force => true)
|
18
19
|
end
|
19
|
-
|
20
|
+
|
20
21
|
end
|
21
22
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'active_support/deprecation'
|
2
|
+
require 'devise_invitable/models/authenticatable'
|
2
3
|
|
3
4
|
module Devise
|
4
5
|
module Models
|
@@ -96,7 +97,7 @@ module Devise
|
|
96
97
|
self.accept_invitation
|
97
98
|
self.confirmed_at = self.invitation_accepted_at if self.respond_to?(:confirmed_at)
|
98
99
|
self.save
|
99
|
-
end
|
100
|
+
end.tap { @accepting_invitation = false }
|
100
101
|
end
|
101
102
|
end
|
102
103
|
|
@@ -167,6 +168,11 @@ module Devise
|
|
167
168
|
super unless !accepting_invitation? && block_from_invitation?
|
168
169
|
end
|
169
170
|
|
171
|
+
# Prevent password changed email when accepting invitation
|
172
|
+
def send_password_change_notification?
|
173
|
+
super && !accepting_invitation?
|
174
|
+
end
|
175
|
+
|
170
176
|
# Enforce password when invitation is being accepted
|
171
177
|
def password_required?
|
172
178
|
(accepting_invitation? && self.class.require_password_on_accepting) || super
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Devise
|
2
|
+
module Models
|
3
|
+
module Authenticatable
|
4
|
+
BLACKLIST_FOR_SERIALIZATION.concat %i[
|
5
|
+
invitation_token invitation_created_at invitation_sent_at
|
6
|
+
invitation_accepted_at invitation_limit invited_by_type
|
7
|
+
invited_by_id invitations_count
|
8
|
+
]
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -6,7 +6,13 @@ module ActiveRecord
|
|
6
6
|
source_root File.expand_path("../templates", __FILE__)
|
7
7
|
|
8
8
|
def copy_devise_migration
|
9
|
-
migration_template "migration.rb", "db/migrate/devise_invitable_add_to_#{table_name}.rb"
|
9
|
+
migration_template "migration.rb", "db/migrate/devise_invitable_add_to_#{table_name}.rb", migration_version: migration_version
|
10
|
+
end
|
11
|
+
|
12
|
+
def migration_version
|
13
|
+
if Rails.version.start_with? '5.'
|
14
|
+
"[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
|
15
|
+
end
|
10
16
|
end
|
11
17
|
end
|
12
18
|
end
|
@@ -31,7 +31,7 @@ class DeviseInvitable::RegistrationsControllerTest < ActionController::TestCase
|
|
31
31
|
|
32
32
|
# sign_up the invitee
|
33
33
|
assert_difference('ActionMailer::Base.deliveries.size') do
|
34
|
-
post :create, :user => {:email => invitee_email, :password => "1password", :bio => '.'}
|
34
|
+
post :create, params: {:user => {:email => invitee_email, :password => "1password", :bio => '.'}}
|
35
35
|
end
|
36
36
|
|
37
37
|
@invitee = User.where(:email => invitee_email).first
|
@@ -57,7 +57,7 @@ class DeviseInvitable::RegistrationsControllerTest < ActionController::TestCase
|
|
57
57
|
register_email = "invitee@example.org"
|
58
58
|
# sign_up the invitee
|
59
59
|
assert_difference('ActionMailer::Base.deliveries.size') do
|
60
|
-
post :create, :user => {:email => register_email, :password => "1password", :bio => '.'}
|
60
|
+
post :create, params: {:user => {:email => register_email, :password => "1password", :bio => '.'}}
|
61
61
|
end
|
62
62
|
assert_nil @controller.current_user
|
63
63
|
|
@@ -85,7 +85,7 @@ class DeviseInvitable::RegistrationsControllerTest < ActionController::TestCase
|
|
85
85
|
|
86
86
|
assert_nil Admin.where(:email => invitee_email).first
|
87
87
|
|
88
|
-
post :create, :admin => {:email => invitee_email, :password => "1password"}
|
88
|
+
post :create, params: {:admin => {:email => invitee_email, :password => "1password"}}
|
89
89
|
|
90
90
|
@invitee = Admin.where(:email => invitee_email).first
|
91
91
|
assert @invitee.encrypted_password.present?
|
@@ -95,14 +95,14 @@ class DeviseInvitable::RegistrationsControllerTest < ActionController::TestCase
|
|
95
95
|
@request.env["devise.mapping"] = Devise.mappings[:admin]
|
96
96
|
invitee_email = "invitee@example.org"
|
97
97
|
|
98
|
-
post :create, :admin => {:email => invitee_email, :password => "1password"}
|
98
|
+
post :create, params: {:admin => {:email => invitee_email, :password => "1password"}}
|
99
99
|
assert_response 302
|
100
100
|
|
101
101
|
@invitee = Admin.where(:email => invitee_email).first
|
102
102
|
assert @invitee.encrypted_password.present?
|
103
103
|
|
104
104
|
sign_out @invitee
|
105
|
-
post :create, :admin => {:email => invitee_email, :password => "2password"}
|
105
|
+
post :create, params: {:admin => {:email => invitee_email, :password => "2password"}}
|
106
106
|
assert_response 200
|
107
107
|
assert_equal @invitee.encrypted_password, Admin.where(:email => invitee_email).first.encrypted_password
|
108
108
|
assert @controller.send(:resource).errors.present?
|
@@ -252,7 +252,7 @@ class InvitationTest < ActionDispatch::IntegrationTest
|
|
252
252
|
sign_in_as_user admin
|
253
253
|
|
254
254
|
send_invitation new_admin_path
|
255
|
-
assert_equal
|
255
|
+
assert_equal root_path, current_path
|
256
256
|
assert page.has_css?('p#notice', :text => 'An invitation email has been sent to user@test.com.')
|
257
257
|
end
|
258
258
|
|
@@ -261,7 +261,7 @@ class InvitationTest < ActionDispatch::IntegrationTest
|
|
261
261
|
sign_in_as_user admin
|
262
262
|
|
263
263
|
send_invitation new_free_invitation_path
|
264
|
-
assert_equal
|
264
|
+
assert_equal root_path, current_path
|
265
265
|
assert page.has_css?('p#notice', :text => 'An invitation email has been sent to user@test.com.')
|
266
266
|
end
|
267
267
|
end
|
@@ -619,6 +619,24 @@ class InvitableTest < ActiveSupport::TestCase
|
|
619
619
|
refute_predicate user, :confirmed?
|
620
620
|
end
|
621
621
|
|
622
|
+
test 'should not send password change notification when accepting invitation' do
|
623
|
+
send_password_change_notification = User.send_password_change_notification
|
624
|
+
|
625
|
+
begin
|
626
|
+
User.send_password_change_notification = true
|
627
|
+
|
628
|
+
user = User.invite!(:email => "valid@email.com")
|
629
|
+
|
630
|
+
assert_no_difference('ActionMailer::Base.deliveries.size') do
|
631
|
+
user.password = user.password_confirmation = '123456789'
|
632
|
+
user.accept_invitation!
|
633
|
+
end
|
634
|
+
|
635
|
+
ensure
|
636
|
+
User.send_password_change_notification = send_password_change_notification
|
637
|
+
end
|
638
|
+
end
|
639
|
+
|
622
640
|
def assert_callbacks_fired(callback, user)
|
623
641
|
assert_callbacks_status callback, user, true
|
624
642
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class ApplicationController < ActionController::Base
|
2
2
|
protect_from_forgery
|
3
|
-
|
3
|
+
before_action :configure_permitted_parameters, :if => :devise_controller?
|
4
4
|
|
5
5
|
protected
|
6
6
|
def after_sign_in_path_for(resource)
|
data/test/test_helper.rb
CHANGED
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
|
+
version: 1.7.3
|
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: 2018-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -75,7 +75,8 @@ files:
|
|
75
75
|
- lib/devise_invitable/inviter.rb
|
76
76
|
- lib/devise_invitable/mailer.rb
|
77
77
|
- lib/devise_invitable/mapping.rb
|
78
|
-
- lib/devise_invitable/
|
78
|
+
- lib/devise_invitable/models.rb
|
79
|
+
- lib/devise_invitable/models/authenticatable.rb
|
79
80
|
- lib/devise_invitable/parameter_sanitizer.rb
|
80
81
|
- lib/devise_invitable/rails.rb
|
81
82
|
- lib/devise_invitable/routes.rb
|