devise_invitable 2.0.5 → 2.0.6
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/CHANGELOG.md +4 -0
- data/README.rdoc +57 -2
- data/app/controllers/devise/invitations_controller.rb +2 -2
- data/config/locales/de.yml +31 -31
- data/lib/devise_invitable/models.rb +3 -2
- data/lib/devise_invitable/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3803fa69fe6bdecc811ab934878cc365f31ae0a124e54bbde34ad967752f1d3c
|
4
|
+
data.tar.gz: df5c2b785956d22e8bf69d644326605a649f1fd76b1d19af04d4bcd48a3c15f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 925df2c1ef1a893f9e4d9b376b298fa5e21a4c516d8829d7990aa5e5b4a18a7d288d209658f38a1793c51b5a4fca83cbff814a19f2e725ddd8baa4307f448092
|
7
|
+
data.tar.gz: 4380da8ff7d5ff6e680393ab8f8935dae7b10e3d50271fdfaa839d0968caad99a56282ba6765b3d18f2f70090796c607c0198dc3932f3ac21f24821a8635a4e5
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## 2.0.6
|
2
|
+
- Fix submit form failure with turbolinks, fixes ([#865](https://github.com/scambra/devise_invitable/issues/865))
|
3
|
+
- Fix obsolete symbols in German translation ([#864](https://github.com/scambra/devise_invitable/pull/864))
|
4
|
+
|
1
5
|
## 2.0.5
|
2
6
|
- Fix NoMethodError in random_password when validatable is not used ([#850](https://github.com/scambra/devise_invitable/pull/850))
|
3
7
|
|
data/README.rdoc
CHANGED
@@ -35,14 +35,14 @@ Replace MODEL by the class name you want to add DeviseInvitable, like <tt>User</
|
|
35
35
|
|
36
36
|
Follow the walkthrough for Devise and after it's done, follow this walkthrough.
|
37
37
|
|
38
|
-
|
38
|
+
==== Devise Configuration
|
39
39
|
Add <tt>:invitable</tt> to the <tt>devise</tt> call in your model (we’re assuming here you already have a User model with some Devise modules):
|
40
40
|
|
41
41
|
class User < ActiveRecord::Base
|
42
42
|
devise :database_authenticatable, :confirmable, :invitable
|
43
43
|
end
|
44
44
|
|
45
|
-
|
45
|
+
==== ActiveRecord Migration
|
46
46
|
Add <tt>t.invitable</tt> to your Devise model migration:
|
47
47
|
|
48
48
|
create_table :users do
|
@@ -217,6 +217,61 @@ Here is an example of what your application controller might need to include in
|
|
217
217
|
devise_parameter_sanitizer.permit(:accept_invitation, keys: [:first_name, :last_name, :phone])
|
218
218
|
end
|
219
219
|
|
220
|
+
Here is an example setting a User's first name, last name, and role for a custom invitation:
|
221
|
+
|
222
|
+
#Configuring the InvitationsController to accept :first_name, :last_name, and :role
|
223
|
+
|
224
|
+
class Users::InvitationsController < Devise::InvitationsController
|
225
|
+
before_action :configure_permitted_parameters
|
226
|
+
|
227
|
+
protected
|
228
|
+
|
229
|
+
# Permit the new params here.
|
230
|
+
def configure_permitted_parameters
|
231
|
+
devise_parameter_sanitizer.permit(:invite, keys: [:first_name, :last_name, :role])
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
#Define your roles in the User model
|
236
|
+
|
237
|
+
class User < ApplicationRecord
|
238
|
+
has_many :models
|
239
|
+
|
240
|
+
enum role: {Role 1 Name: 0, Role 2 Name: 1, Role 3 Name: 2, etc...}
|
241
|
+
end
|
242
|
+
|
243
|
+
#In the Invitation view
|
244
|
+
|
245
|
+
<h2><%= t "devise.invitations.new.header" %></h2>
|
246
|
+
|
247
|
+
<%= form_for(resource, as: resource_name, url: invitation_path(resource_name), html: { method: :post }) do |f| %>
|
248
|
+
<%= render "devise/shared/error_messages", resource: resource %>
|
249
|
+
<% resource.class.invite_key_fields.each do |field| -%>
|
250
|
+
<div class="field">
|
251
|
+
<%= f.label field %><br />
|
252
|
+
<%= f.text_field field %>
|
253
|
+
</div>
|
254
|
+
<% end %>
|
255
|
+
|
256
|
+
<div class="field">
|
257
|
+
<%= f.label :first_name %>
|
258
|
+
<%= f.text_field :first_name %>
|
259
|
+
</div>
|
260
|
+
|
261
|
+
<div class="field">
|
262
|
+
<%= f.label :last_name %>
|
263
|
+
<%= f.text_field :last_name %>
|
264
|
+
</div>
|
265
|
+
|
266
|
+
<div class="field">
|
267
|
+
<%= f.label :role %>
|
268
|
+
<%= f.select :role, options_for_select(User.roles.map { |key, value| [key.humanize, key] }), {prompt: "Select Role"} %>
|
269
|
+
</div>
|
270
|
+
|
271
|
+
<div class="actions">
|
272
|
+
<%= f.submit t("devise.invitations.new.submit_button") %>
|
273
|
+
</div>
|
274
|
+
<% end %>
|
220
275
|
|
221
276
|
== Usage
|
222
277
|
|
@@ -31,7 +31,7 @@ class Devise::InvitationsController < DeviseController
|
|
31
31
|
respond_with resource, location: after_invite_path_for(current_inviter, resource)
|
32
32
|
end
|
33
33
|
else
|
34
|
-
respond_with_navigational(resource) { render :new }
|
34
|
+
respond_with_navigational(resource) { render :new, status: :unprocessable_entity }
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -63,7 +63,7 @@ class Devise::InvitationsController < DeviseController
|
|
63
63
|
end
|
64
64
|
else
|
65
65
|
resource.invitation_token = raw_invitation_token
|
66
|
-
respond_with_navigational(resource) { render :edit }
|
66
|
+
respond_with_navigational(resource) { render :edit, status: :unprocessable_entity }
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
data/config/locales/de.yml
CHANGED
@@ -1,31 +1,31 @@
|
|
1
|
-
de:
|
2
|
-
devise:
|
3
|
-
failure:
|
4
|
-
invited: "Du hast bereits eine Einladung erhalten. Nimm die Einladung an um dein Nutzerkonto zu erstellen."
|
5
|
-
invitations:
|
6
|
-
send_instructions: "Eine Einladung wurde an %{email} verschickt."
|
7
|
-
invitation_token_invalid: "Der Einladungs-Code ist ungültig!"
|
8
|
-
updated: "Dein Passwort wurde gesetzt. Du bist nun angemeldet."
|
9
|
-
updated_not_active: "Dein Passwort wurde gesetzt."
|
10
|
-
no_invitations_remaining: "Es gibt keine weiteren Einladungen"
|
11
|
-
invitation_removed: "Deine Einladung wurde gelöscht."
|
12
|
-
new:
|
13
|
-
header: "Einladung schicken"
|
14
|
-
submit_button: "Einladung schicken"
|
15
|
-
edit:
|
16
|
-
header: "Setze ein Passwort"
|
17
|
-
submit_button: "Passwort setzen"
|
18
|
-
mailer:
|
19
|
-
invitation_instructions:
|
20
|
-
subject: "Einladung"
|
21
|
-
hello: "Hallo %{email}"
|
22
|
-
someone_invited_you: "Jemand hat dich zu %{url} eingeladen. Du kannst die Einladung mit dem Link unten annehmen."
|
23
|
-
accept: "Einladung annehmen"
|
24
|
-
accept_until: "Diese Einladung ist gültig bis zum %{due_date}."
|
25
|
-
ignore: "Wenn du die Einladung nicht annehmen willst, ignoriere diese E-Mail einfach
|
26
|
-
time:
|
27
|
-
formats:
|
28
|
-
devise:
|
29
|
-
mailer:
|
30
|
-
invitation_instructions:
|
31
|
-
accept_until_format: "%d. %B %Y %H:%M"
|
1
|
+
de:
|
2
|
+
devise:
|
3
|
+
failure:
|
4
|
+
invited: "Du hast bereits eine Einladung erhalten. Nimm die Einladung an um dein Nutzerkonto zu erstellen."
|
5
|
+
invitations:
|
6
|
+
send_instructions: "Eine Einladung wurde an %{email} verschickt."
|
7
|
+
invitation_token_invalid: "Der Einladungs-Code ist ungültig!"
|
8
|
+
updated: "Dein Passwort wurde gesetzt. Du bist nun angemeldet."
|
9
|
+
updated_not_active: "Dein Passwort wurde gesetzt."
|
10
|
+
no_invitations_remaining: "Es gibt keine weiteren Einladungen"
|
11
|
+
invitation_removed: "Deine Einladung wurde gelöscht."
|
12
|
+
new:
|
13
|
+
header: "Einladung schicken"
|
14
|
+
submit_button: "Einladung schicken"
|
15
|
+
edit:
|
16
|
+
header: "Setze ein Passwort"
|
17
|
+
submit_button: "Passwort setzen"
|
18
|
+
mailer:
|
19
|
+
invitation_instructions:
|
20
|
+
subject: "Einladung"
|
21
|
+
hello: "Hallo %{email}"
|
22
|
+
someone_invited_you: "Jemand hat dich zu %{url} eingeladen. Du kannst die Einladung mit dem Link unten annehmen."
|
23
|
+
accept: "Einladung annehmen"
|
24
|
+
accept_until: "Diese Einladung ist gültig bis zum %{due_date}."
|
25
|
+
ignore: "Wenn du die Einladung nicht annehmen willst, ignoriere diese E-Mail einfach. Es wird kein Benutzerkonto erstellt solange du nicht die Einladung mittels des Links oben annimmst."
|
26
|
+
time:
|
27
|
+
formats:
|
28
|
+
devise:
|
29
|
+
mailer:
|
30
|
+
invitation_instructions:
|
31
|
+
accept_until_format: "%d. %B %Y %H:%M"
|
@@ -158,7 +158,8 @@ module Devise
|
|
158
158
|
self.downcase_keys if new_record_and_responds_to?(:downcase_keys)
|
159
159
|
self.strip_whitespace if new_record_and_responds_to?(:strip_whitespace)
|
160
160
|
|
161
|
-
|
161
|
+
validate = options.key?(:validate) ? options[:validate] : self.class.validate_on_invite
|
162
|
+
if save(validate: validate)
|
162
163
|
self.invited_by.decrement_invitation_limit! if !was_invited and self.invited_by.present?
|
163
164
|
deliver_invitation(options) unless skip_invitation
|
164
165
|
end
|
@@ -324,7 +325,7 @@ module Devise
|
|
324
325
|
end
|
325
326
|
|
326
327
|
yield invitable if block_given?
|
327
|
-
mail = invitable.invite!(nil, options) if invitable.errors.empty?
|
328
|
+
mail = invitable.invite!(nil, options.merge(validate: false)) if invitable.errors.empty?
|
328
329
|
[invitable, mail]
|
329
330
|
end
|
330
331
|
|
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergio Cambra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionmailer
|
@@ -186,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
186
186
|
- !ruby/object:Gem::Version
|
187
187
|
version: '0'
|
188
188
|
requirements: []
|
189
|
-
rubygems_version: 3.0.
|
189
|
+
rubygems_version: 3.0.9
|
190
190
|
signing_key:
|
191
191
|
specification_version: 4
|
192
192
|
summary: An invitation strategy for Devise
|