devise_invitable 0.5.2 → 0.5.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.

@@ -61,7 +61,7 @@ or for a model that already exists, define a migration to add DeviseInvitable to
61
61
 
62
62
  == Model configuration
63
63
 
64
- DeviseInvitable adds four new configuration options:
64
+ DeviseInvitable adds some new configuration options:
65
65
 
66
66
  * invite_for: The period the generated invitation token is valid, after this period, the invited resource won't be able to accept the invitation. When invite_for is 0 (the default), the invitation won't expire.
67
67
 
@@ -83,6 +83,8 @@ or directly as parameters to the <tt>devise</tt> method:
83
83
 
84
84
  * validate_on_invite: force a record to be valid before being actually invited.
85
85
 
86
+ * resend_invitation: resend invitation if user with invited status is invited again. Enabled by default.
87
+
86
88
  For more details, see <tt>config/initializers/devise.rb</tt> (after you invoked the "devise_invitable:install" generator described above).
87
89
 
88
90
  == Configuring views
@@ -170,7 +172,7 @@ You would have a User model which is configured as invitable and an Admin model
170
172
  class ApplicationController < ActionController::Base
171
173
  protected
172
174
  def authenticate_inviter!
173
- authenticate_admin!
175
+ authenticate_admin!(true)
174
176
  end
175
177
  end
176
178
 
@@ -44,6 +44,15 @@ module Devise
44
44
  # config.invite_key = :email
45
45
  mattr_accessor :invite_key
46
46
  @@invite_key = :email
47
+
48
+ # Public: Resend invitation if user with invited status is invited again
49
+ # (default: true)
50
+ #
51
+ # Example (in config/initializers/devise.rb)
52
+ #
53
+ # config.resend_invitation = false
54
+ mattr_accessor :resend_invitation
55
+ @@resend_invitation = true
47
56
  end
48
57
 
49
58
  Devise.add_module :invitable, :controller => :invitations, :model => 'devise_invitable/model', :route => :invitation
@@ -118,6 +118,8 @@ module Devise
118
118
  # Attempt to find a user by it's email. If a record is not found, create a new
119
119
  # user and send invitation to it. If user is found, returns the user with an
120
120
  # email already exists error.
121
+ # If user is found and still have pending invitation, email is resend unless
122
+ # resend_invitation is set to false
121
123
  # Attributes must contain the user email, other attributes will be set in the record
122
124
  def invite!(attributes={}, invited_by=nil, &block)
123
125
  invitable = find_or_initialize_with_error_by(invite_key, attributes.delete(invite_key))
@@ -127,7 +129,7 @@ module Devise
127
129
  if invitable.new_record?
128
130
  invitable.errors.clear if invitable.email.try(:match, Devise.email_regexp)
129
131
  else
130
- invitable.errors.add(invite_key, :taken) unless invitable.invited?
132
+ invitable.errors.add(invite_key, :taken) unless invitable.invited? && self.resend_invitation
131
133
  end
132
134
 
133
135
  if invitable.errors.empty?
@@ -161,6 +163,7 @@ module Devise
161
163
  Devise::Models.config(self, :validate_on_invite)
162
164
  Devise::Models.config(self, :invitation_limit)
163
165
  Devise::Models.config(self, :invite_key)
166
+ Devise::Models.config(self, :resend_invitation)
164
167
  end
165
168
  end
166
169
  end
@@ -1,3 +1,3 @@
1
1
  module DeviseInvitable
2
- VERSION = '0.5.2'
2
+ VERSION = '0.5.3'
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise_invitable
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 2
10
- version: 0.5.2
9
+ - 3
10
+ version: 0.5.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sergio Cambra
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-07-04 00:00:00 +02:00
18
+ date: 2011-07-22 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency