devise_invitable 0.5.6 → 0.5.7

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.

@@ -26,7 +26,7 @@ class Devise::InvitationsController < ApplicationController
26
26
 
27
27
  # GET /resource/invitation/accept?invitation_token=abcdef
28
28
  def edit
29
- if params[:invitation_token] && self.resource = resource_class.first(:conditions => { :invitation_token => params[:invitation_token] })
29
+ if params[:invitation_token] && self.resource = resource_class.to_adapter.find_first( :invitation_token => params[:invitation_token] )
30
30
  render_with_scope :edit
31
31
  else
32
32
  set_flash_message(:alert, :invitation_token_invalid)
@@ -55,7 +55,7 @@ class Devise::InvitationsController < ApplicationController
55
55
  def has_invitations_left?
56
56
  unless current_inviter.nil? || current_inviter.has_invitations_left?
57
57
  build_resource
58
- set_flash_message :alert, :no_invitations_remaining
58
+ set_flash_message :alert, :no_invitations_remaining
59
59
  respond_with_navigational(resource) { render_with_scope :new }
60
60
  end
61
61
  end
@@ -68,3 +68,4 @@ class Devise::InvitationsController < ApplicationController
68
68
  after_sign_in_path_for(resource)
69
69
  end
70
70
  end
71
+
@@ -33,8 +33,8 @@ module Devise
33
33
  def accept_invitation!
34
34
  if self.invited? && self.valid?
35
35
  self.invitation_token = nil
36
- self.invitation_accepted_at = Time.now.utc if has_attribute? :invitation_accepted_at
37
- self.save
36
+ self.invitation_accepted_at = Time.now.utc # if has_attribute? :invitation_accepted_at
37
+ self.save(:validate => false)
38
38
  end
39
39
  end
40
40
 
@@ -46,11 +46,12 @@ module Devise
46
46
  # Reset invitation token and send invitation again
47
47
  def invite!
48
48
  @skip_password = true
49
+ was_invited = invited?
49
50
  self.skip_confirmation! if self.new_record? && self.respond_to?(:skip_confirmation!)
50
51
  generate_invitation_token if self.invitation_token.nil?
51
52
  self.invitation_sent_at = Time.now.utc
52
- if save(:validate => self.class.validate_on_invite)
53
- self.invited_by.decrement_invitation_limit! if self.invited_by
53
+ if save(:validate => false)
54
+ self.invited_by.decrement_invitation_limit! if !was_invited and self.invited_by.present?
54
55
  deliver_invitation unless @skip_invitation
55
56
  end
56
57
  end
@@ -125,29 +126,30 @@ module Devise
125
126
  invitable.attributes = attributes
126
127
  invitable.invited_by = invited_by
127
128
 
129
+ invitable.valid? if self.validate_on_invite
128
130
  if invitable.new_record?
129
- invitable.errors.clear if invitable.email.try(:match, Devise.email_regexp)
131
+ invitable.errors.clear if !self.validate_on_invite and invitable.email.try(:match, Devise.email_regexp)
130
132
  else
131
133
  invitable.errors.add(invite_key, :taken) unless invitable.invited? && self.resend_invitation
132
134
  end
133
135
 
134
- if self.validate_on_invite || invitable.errors.empty?
136
+ if invitable.errors.empty?
135
137
  yield invitable if block_given?
136
138
  mail = invitable.invite!
137
139
  end
138
140
  [invitable, mail]
139
141
  end
140
-
142
+
141
143
  def invite!(attributes={}, invited_by=nil, &block)
142
144
  invitable, mail = _invite(attributes, invited_by, &block)
143
145
  invitable
144
146
  end
145
-
147
+
146
148
  def invite_mail!(attributes={}, invited_by=nil, &block)
147
149
  invitable, mail = _invite(attributes, invited_by, &block)
148
150
  mail
149
151
  end
150
-
152
+
151
153
  # Attempt to find a user by it's invitation_token to set it's password.
152
154
  # If a user is found, reset it's password and automatically try saving
153
155
  # the record. If not user is found, returns a new user containing an
@@ -177,3 +179,4 @@ module Devise
177
179
  end
178
180
  end
179
181
  end
182
+
@@ -1,3 +1,3 @@
1
1
  module DeviseInvitable
2
- VERSION = '0.5.6'
2
+ VERSION = '0.5.7'
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: 7
4
+ hash: 5
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 6
10
- version: 0.5.6
9
+ - 7
10
+ version: 0.5.7
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-10-25 00:00:00 Z
18
+ date: 2011-11-09 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: bundler