devise_invitable 1.3.6 → 1.4.0
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 +7 -7
- data/CHANGELOG +4 -0
- data/README.rdoc +19 -1
- data/app/controllers/devise/invitations_controller.rb +12 -10
- data/app/views/devise/mailer/invitation_instructions.html.erb +4 -4
- data/config/locales/en.yml +2 -0
- data/lib/devise_invitable/model.rb +6 -6
- data/lib/devise_invitable/version.rb +1 -1
- data/lib/generators/devise_invitable/templates/simple_form_for/invitations/edit.html.erb +1 -1
- data/lib/generators/devise_invitable/templates/simple_form_for/invitations/new.html.erb +1 -1
- data/test/integration_tests_helper.rb +1 -1
- metadata +61 -52
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
|
4
|
-
|
5
|
-
SHA512:
|
6
|
-
|
7
|
-
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 49059f27df2618f9c0491fd1b7578b33619f2ef5
|
4
|
+
data.tar.gz: da0b1ff3962cba2784b8c082c013fb483ee0517e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 56e5cc31bd011a67887ea3338ee66682dc398008f4a18f094fec9084b0635efc8684d5251aca72a9d7daecf228ea06aeec84bca49a8dd24bd3750c063f7b2e56
|
7
|
+
data.tar.gz: 162bc6c70f81f0b65ca73233a5ebb5ac53895b5e6c57f4085d522807592feccb29ce93c113e1d67d974fa95ebf026054d137a6a5c01c1af3913bf84df14d2f7a
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
= 1.4.0
|
2
|
+
Override active_for_authentication? and inactive_message instead of valid_password?
|
3
|
+
To use counter_cache, invited_by_counter_cache must be set, no more checking of invitations_count to enable counter cache
|
4
|
+
|
1
5
|
= 1.3.0
|
2
6
|
Now devise 3.1 compatible, @token must be used instead of @resource.invitation_token in mail views
|
3
7
|
|
data/README.rdoc
CHANGED
@@ -233,11 +233,16 @@ To send an invitation to a user, use the <tt>invite!</tt> class method. <tt>:ema
|
|
233
233
|
|
234
234
|
If you want to create the invitation but not send it, you can set <tt>skip_invitation</tt> to true.
|
235
235
|
|
236
|
-
User.invite!(:email => "new_user@example.com", :name => "John Doe") do |u|
|
236
|
+
user = User.invite!(:email => "new_user@example.com", :name => "John Doe") do |u|
|
237
237
|
u.skip_invitation = true
|
238
238
|
end
|
239
239
|
# => the record will be created, but the invitation email will not be sent
|
240
240
|
|
241
|
+
When generating the <tt>accept_user_invitation_url</tt> yourself, you must use the <tt>raw_invitation_token</tt>
|
242
|
+
the value is temporarily available when you invite a user and will be decrypted when recieved.
|
243
|
+
|
244
|
+
accept_user_invitation_url(:invitation_token => user.raw_invitation_token)
|
245
|
+
|
241
246
|
When skip_invitation is used, you must also then set the invitation_sent_at field when the user is sent their
|
242
247
|
token. Failure to do so will yield "Invalid invitation token" errors when the user attempts to accept the invite.
|
243
248
|
You can set it like so:
|
@@ -252,6 +257,11 @@ You can add :skip_invitation to attributes hash if skip_invitation is added to a
|
|
252
257
|
Skip_invitation skips sending the email, but sets invitation_token, so invited_to_sign_up? on the
|
253
258
|
resulting user returns true.
|
254
259
|
|
260
|
+
**Warning**
|
261
|
+
|
262
|
+
When using skip_invitation you must send the email with the user object instance that generated the tokens, as
|
263
|
+
user.raw_invitation_token is available only to the instance and is not persisted in the database.
|
264
|
+
|
255
265
|
You can send an invitation to an existing user if your workflow creates them separately:
|
256
266
|
|
257
267
|
user = User.find(42)
|
@@ -261,6 +271,8 @@ You can also set <tt>invited_by</tt> when using the <tt>invite!</tt> class metho
|
|
261
271
|
|
262
272
|
User.invite!({:email => "new_user@example.com"}, current_user) # current_user will be set as invited_by
|
263
273
|
|
274
|
+
|
275
|
+
|
264
276
|
=== Accept an invitation
|
265
277
|
|
266
278
|
To accept an invitation with a token use the <tt>accept_invitation!</tt> class method. <tt>:invitation_token</tt> must be present in the parameters hash. You can also include other attributes in the hash.
|
@@ -369,6 +381,12 @@ Take a look at the generated locale file (in <tt>config/locales/devise_invitable
|
|
369
381
|
|
370
382
|
DeviseInvitable supports ActiveRecord and Mongoid, like Devise.
|
371
383
|
|
384
|
+
== Wiki
|
385
|
+
|
386
|
+
It's possible to find additional information about DeviseInvitable on the Wiki:
|
387
|
+
|
388
|
+
https://github.com/scambra/devise_invitable/wiki
|
389
|
+
|
372
390
|
== Testing
|
373
391
|
|
374
392
|
To test DeviseInvitable for the ActiveRecord ORM with RVM, Ruby 1.9.2, and Rubygems 1.8.17:
|
@@ -18,7 +18,9 @@ class Devise::InvitationsController < DeviseController
|
|
18
18
|
|
19
19
|
if resource.errors.empty?
|
20
20
|
yield resource if block_given?
|
21
|
-
|
21
|
+
if is_flashing_format? && self.resource.invitation_sent_at
|
22
|
+
set_flash_message :notice, :send_instructions, :email => self.resource.email
|
23
|
+
end
|
22
24
|
respond_with resource, :location => after_invite_path_for(resource)
|
23
25
|
else
|
24
26
|
respond_with_navigational(resource) { render :new }
|
@@ -37,19 +39,19 @@ class Devise::InvitationsController < DeviseController
|
|
37
39
|
|
38
40
|
if resource.errors.empty?
|
39
41
|
yield resource if block_given?
|
40
|
-
flash_message = resource.active_for_authentication? ? :updated : :updated_not_active
|
41
|
-
set_flash_message :notice, flash_message
|
42
|
+
flash_message = resource.active_for_authentication? ? :updated : :updated_not_active
|
43
|
+
set_flash_message :notice, flash_message if is_flashing_format?
|
42
44
|
sign_in(resource_name, resource)
|
43
45
|
respond_with resource, :location => after_accept_path_for(resource)
|
44
46
|
else
|
45
47
|
respond_with_navigational(resource){ render :edit }
|
46
48
|
end
|
47
49
|
end
|
48
|
-
|
50
|
+
|
49
51
|
# GET /resource/invitation/remove?invitation_token=abcdef
|
50
52
|
def destroy
|
51
53
|
resource.destroy
|
52
|
-
set_flash_message :notice, :invitation_removed
|
54
|
+
set_flash_message :notice, :invitation_removed if is_flashing_format?
|
53
55
|
redirect_to after_sign_out_path_for(resource_name)
|
54
56
|
end
|
55
57
|
|
@@ -58,7 +60,7 @@ class Devise::InvitationsController < DeviseController
|
|
58
60
|
def invite_resource(&block)
|
59
61
|
resource_class.invite!(invite_params, current_inviter, &block)
|
60
62
|
end
|
61
|
-
|
63
|
+
|
62
64
|
def accept_resource
|
63
65
|
resource_class.accept_invitation!(update_resource_params)
|
64
66
|
end
|
@@ -70,14 +72,14 @@ class Devise::InvitationsController < DeviseController
|
|
70
72
|
def has_invitations_left?
|
71
73
|
unless current_inviter.nil? || current_inviter.has_invitations_left?
|
72
74
|
self.resource = resource_class.new
|
73
|
-
set_flash_message :alert, :no_invitations_remaining
|
75
|
+
set_flash_message :alert, :no_invitations_remaining if is_flashing_format?
|
74
76
|
respond_with_navigational(resource) { render :new }
|
75
77
|
end
|
76
78
|
end
|
77
|
-
|
79
|
+
|
78
80
|
def resource_from_invitation_token
|
79
81
|
unless params[:invitation_token] && self.resource = resource_class.find_by_invitation_token(params[:invitation_token], true)
|
80
|
-
set_flash_message(:alert, :invitation_token_invalid)
|
82
|
+
set_flash_message(:alert, :invitation_token_invalid) if is_flashing_format?
|
81
83
|
redirect_to after_sign_out_path_for(resource_name)
|
82
84
|
end
|
83
85
|
end
|
@@ -89,6 +91,6 @@ class Devise::InvitationsController < DeviseController
|
|
89
91
|
def update_resource_params
|
90
92
|
devise_parameter_sanitizer.sanitize(:accept_invitation)
|
91
93
|
end
|
92
|
-
|
94
|
+
|
93
95
|
end
|
94
96
|
|
@@ -1,7 +1,7 @@
|
|
1
|
-
<p><%=
|
1
|
+
<p><%= t("devise.mailer.invitation_instructions.hello", email: @resource.email) %></p>
|
2
2
|
|
3
|
-
<p><%=
|
3
|
+
<p><%= t("devise.mailer.invitation_instructions.someone_invited_you", url: root_url) %></p>
|
4
4
|
|
5
|
-
<p><%= link_to
|
5
|
+
<p><%= link_to t("devise.mailer.invitation_instructions.accept"), accept_invitation_url(@resource, :invitation_token => @token) %></p>
|
6
6
|
|
7
|
-
<p><%=
|
7
|
+
<p><%= t("devise.mailer.invitation_instructions.ignore").html_safe %></p>
|
data/config/locales/en.yml
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
en:
|
2
2
|
devise:
|
3
|
+
failure:
|
4
|
+
invited: 'You have a pending invitation, accept it to finish creating your account.'
|
3
5
|
invitations:
|
4
6
|
send_instructions: 'An invitation email has been sent to %{email}.'
|
5
7
|
invitation_token_invalid: 'The invitation token provided is not valid!'
|
@@ -34,12 +34,8 @@ module Devise
|
|
34
34
|
else
|
35
35
|
{:polymorphic => true}
|
36
36
|
end
|
37
|
-
if defined?(ActiveRecord) && self < ActiveRecord::Base
|
37
|
+
if defined?(ActiveRecord) && defined?(ActiveRecord::Base) && self < ActiveRecord::Base
|
38
38
|
counter_cache = Devise.invited_by_counter_cache
|
39
|
-
if !counter_cache && Devise.invited_by_class_name
|
40
|
-
klass = Devise.invited_by_class_name.constantize
|
41
|
-
counter_cache = klass.table_exists? && klass.columns_hash['invitations_count'].try('name')
|
42
|
-
end
|
43
39
|
belongs_to_options.merge! :counter_cache => counter_cache if counter_cache
|
44
40
|
end
|
45
41
|
belongs_to :invited_by, belongs_to_options
|
@@ -138,10 +134,14 @@ module Devise
|
|
138
134
|
end
|
139
135
|
|
140
136
|
# Only verify password when is not invited
|
141
|
-
def
|
137
|
+
def active_for_authentication?
|
142
138
|
super unless invited_to_sign_up?
|
143
139
|
end
|
144
140
|
|
141
|
+
def inactive_message
|
142
|
+
invited_to_sign_up? ? :invited : super
|
143
|
+
end
|
144
|
+
|
145
145
|
def after_password_reset
|
146
146
|
super
|
147
147
|
accept_invitation! if invited_to_sign_up?
|
@@ -24,7 +24,7 @@ class ActionDispatch::IntegrationTest
|
|
24
24
|
visit send("new_#{resource_name}_session_path")
|
25
25
|
fill_in "#{resource_name}_email", :with => user.email
|
26
26
|
fill_in "#{resource_name}_password", :with => user.password
|
27
|
-
click_button '
|
27
|
+
click_button 'Log in'
|
28
28
|
end
|
29
29
|
|
30
30
|
# Fix assert_redirect_to in integration sessions because they don't take into
|
metadata
CHANGED
@@ -1,59 +1,71 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise_invitable
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
|
-
authors:
|
6
|
+
authors:
|
7
7
|
- Sergio Cambra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2014-10-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
15
14
|
name: bundler
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Version
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
21
19
|
version: 1.1.0
|
22
20
|
type: :development
|
23
|
-
version_requirements: *id001
|
24
|
-
- !ruby/object:Gem::Dependency
|
25
|
-
name: actionmailer
|
26
21
|
prerelease: false
|
27
|
-
|
28
|
-
requirements:
|
29
|
-
- -
|
30
|
-
- !ruby/object:Gem::Version
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.1.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: actionmailer
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
31
33
|
version: 3.2.6
|
32
34
|
- - <
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
version:
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '5'
|
35
37
|
type: :runtime
|
36
|
-
version_requirements: *id002
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: devise
|
39
38
|
prerelease: false
|
40
|
-
|
41
|
-
requirements:
|
42
|
-
- -
|
43
|
-
- !ruby/object:Gem::Version
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 3.2.6
|
44
|
+
- - <
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '5'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: devise
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - '>='
|
52
|
+
- !ruby/object:Gem::Version
|
44
53
|
version: 3.2.0
|
45
54
|
type: :runtime
|
46
|
-
|
47
|
-
|
48
|
-
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 3.2.0
|
61
|
+
description: It adds support for send invitations by email (it requires to be authenticated)
|
62
|
+
and accept the invitation by setting a password.
|
63
|
+
email:
|
49
64
|
- sergio@entrecables.com
|
50
65
|
executables: []
|
51
|
-
|
52
66
|
extensions: []
|
53
|
-
|
54
67
|
extra_rdoc_files: []
|
55
|
-
|
56
|
-
files:
|
68
|
+
files:
|
57
69
|
- app/controllers/devise/invitations_controller.rb
|
58
70
|
- app/controllers/devise_invitable/registrations_controller.rb
|
59
71
|
- app/views/devise/invitations/edit.html.erb
|
@@ -133,35 +145,33 @@ files:
|
|
133
145
|
- test/routes_test.rb
|
134
146
|
- test/test_helper.rb
|
135
147
|
homepage: https://github.com/scambra/devise_invitable
|
136
|
-
licenses:
|
148
|
+
licenses:
|
137
149
|
- MIT
|
138
150
|
metadata: {}
|
139
|
-
|
140
151
|
post_install_message:
|
141
|
-
rdoc_options:
|
152
|
+
rdoc_options:
|
142
153
|
- --main
|
143
154
|
- README.rdoc
|
144
155
|
- --charset=UTF-8
|
145
|
-
require_paths:
|
156
|
+
require_paths:
|
146
157
|
- lib
|
147
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
148
|
-
requirements:
|
149
|
-
- -
|
150
|
-
- !ruby/object:Gem::Version
|
158
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
159
|
+
requirements:
|
160
|
+
- - '>='
|
161
|
+
- !ruby/object:Gem::Version
|
151
162
|
version: 1.8.6
|
152
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
|
-
requirements:
|
154
|
-
- -
|
155
|
-
- !ruby/object:Gem::Version
|
163
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - '>='
|
166
|
+
- !ruby/object:Gem::Version
|
156
167
|
version: 1.3.6
|
157
168
|
requirements: []
|
158
|
-
|
159
169
|
rubyforge_project:
|
160
|
-
rubygems_version: 2.
|
170
|
+
rubygems_version: 2.1.11
|
161
171
|
signing_key:
|
162
172
|
specification_version: 4
|
163
173
|
summary: An invitation strategy for Devise
|
164
|
-
test_files:
|
174
|
+
test_files:
|
165
175
|
- test/functional/controller_helpers_test.rb
|
166
176
|
- test/functional/registrations_controller_test.rb
|
167
177
|
- test/generators/views_generator_test.rb
|
@@ -213,4 +223,3 @@ test_files:
|
|
213
223
|
- test/rails_app/script/rails
|
214
224
|
- test/routes_test.rb
|
215
225
|
- test/test_helper.rb
|
216
|
-
has_rdoc:
|