devise_invitable 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of devise_invitable might be problematic. Click here for more details.

data/README.rdoc CHANGED
@@ -90,7 +90,7 @@ or directly as parameters to the <tt>devise</tt> method:
90
90
 
91
91
  * invitation_limit: The number of invitations users can send. The default value of nil means users can send as many invites as they want. A setting of 0 means they can't send invitations. A setting n > 0 means they can send n invitations.
92
92
 
93
- * invite_key: The key to be used to check existing users when sending an invitation. You can use multiple keys. This value must be a hash with the invite key as hash keys, and regexp to validate format as values. If you don't to validate the key you can set nil as validation format. The default value is looking for users by email and validating with Devise.email_regexp {:email => Devise.email_regexp}.
93
+ * invite_key: The key to be used to check existing users when sending an invitation. You can use multiple keys. This value must be a hash with the invite key as hash keys, and regexp to validate format as values. If you don't want to validate the key you can set nil as validation format. The default value is looking for users by email and validating with Devise.email_regexp {:email => Devise.email_regexp}.
94
94
 
95
95
  * validate_on_invite: force a record to be valid before being actually invited.
96
96
 
@@ -58,13 +58,5 @@ class Devise::InvitationsController < DeviseController
58
58
  respond_with_navigational(resource) { render :new }
59
59
  end
60
60
  end
61
-
62
- def after_invite_path_for(resource)
63
- after_sign_in_path_for(resource)
64
- end
65
-
66
- def after_accept_path_for(resource)
67
- after_sign_in_path_for(resource)
68
- end
69
61
  end
70
62
 
@@ -0,0 +1,16 @@
1
+ es:
2
+ devise:
3
+ invitations:
4
+ send_instructions: "Una invitación de correo se ha enviado para %{email}."
5
+ invitation_token_invalid: "El token de invitación no es valido!"
6
+ updated: "Tu contraseña se ha captura con éxito, ya te encuentras dentro del sistema."
7
+ no_invitations_remaining: "No quedan más invitaciones"
8
+ new:
9
+ header: "Enviar Invitación"
10
+ submit_button: "Envia una invitación"
11
+ edit:
12
+ header: "Establecer contraseña"
13
+ submit_button: "Guardar mi contraseña"
14
+ mailer:
15
+ invitation_instructions:
16
+ subject: "Instruciones de la invitación"
@@ -1,7 +1,22 @@
1
1
  module DeviseInvitable::Controllers::Helpers
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ hide_action :after_invite_path_for, :after_accept_path_for
6
+ end
7
+
8
+ def after_invite_path_for(resource)
9
+ after_sign_in_path_for(resource)
10
+ end
11
+
12
+ def after_accept_path_for(resource)
13
+ after_sign_in_path_for(resource)
14
+ end
15
+
2
16
  protected
3
17
  def authenticate_inviter!
4
18
  send(:"authenticate_#{resource_name}!", :force => true)
5
19
  end
20
+
6
21
  end
7
22
  ActionController::Base.send :include, DeviseInvitable::Controllers::Helpers
@@ -11,7 +11,7 @@ module DeviseInvitable::Controllers::Registrations
11
11
  resource = resource_class.where(:email => hash[:email], :encrypted_password => '').first
12
12
  if resource
13
13
  @invitation_info = Hash[resource.invitation_fields.map {|field|
14
- [field, resource[field]]
14
+ [field, resource.send(field)]
15
15
  }]
16
16
  resource.destroy
17
17
  end
@@ -31,7 +31,7 @@ module DeviseInvitable::Controllers::Registrations
31
31
  resource = resource_class.where(:email => params[resource_name][:email], :invited_by_id => nil).first
32
32
  if resource && @invitation_info
33
33
  resource.invitation_fields.each do |field|
34
- resource[field] = @invitation_info[field]
34
+ resource.send("#{field}=", @invitation_info[field])
35
35
  end
36
36
  resource.save!
37
37
  end
@@ -39,11 +39,11 @@ module Devise
39
39
 
40
40
  attr_writer :skip_password
41
41
 
42
- scope :invitation_not_accepted, where(:invitation_accepted_at => nil)
42
+ scope :invitation_not_accepted, lambda { where(:invitation_accepted_at => nil) }
43
43
  if defined?(Mongoid) && self < Mongoid::Document
44
- scope :invitation_accepted, where(:invitation_accepted_at.ne => nil)
44
+ scope :invitation_accepted, lambda { where(:invitation_accepted_at.ne => nil) }
45
45
  else
46
- scope :invitation_accepted, where(arel_table[:invitation_accepted_at].not_eq(nil))
46
+ scope :invitation_accepted, lambda { where(arel_table[:invitation_accepted_at].not_eq(nil)) }
47
47
 
48
48
  [:before_invitation_accepted, :after_invitation_accepted].each do |callback_method|
49
49
  send callback_method do
@@ -57,7 +57,7 @@ module Devise
57
57
  fields = [:invitation_token, :invitation_sent_at, :invitation_accepted_at,
58
58
  :invitation_limit, :invited_by_id, :invited_by_type]
59
59
  if Devise.invited_by_class_name
60
- fields -= :invited_by_type
60
+ fields -= [:invited_by_type]
61
61
  end
62
62
  fields
63
63
  end
@@ -65,7 +65,7 @@ module Devise
65
65
  def invitation_fields
66
66
  fields = [:invitation_sent_at, :invited_by_id, :invited_by_type]
67
67
  if Devise.invited_by_class_name
68
- fields -= :invited_by_type
68
+ fields -= [:invited_by_type]
69
69
  end
70
70
  fields
71
71
  end
@@ -77,6 +77,7 @@ module Devise
77
77
  if self.invited_to_sign_up? && self.valid?
78
78
  run_callbacks :invitation_accepted do
79
79
  self.invitation_token = nil
80
+ self.confirmed_at = self.invitation_accepted_at if self.respond_to?(:confirmed_at)
80
81
  self.save(:validate => false)
81
82
  end
82
83
  end
@@ -111,7 +112,13 @@ module Devise
111
112
  # Reset invitation token and send invitation again
112
113
  def invite!(invited_by = nil)
113
114
  was_invited = invited_to_sign_up?
114
- self.skip_confirmation! if self.new_record? && self.respond_to?(:skip_confirmation!)
115
+
116
+ # Required to workaround confirmable model's confirmation_required? method
117
+ # being implemented to check for non-nil value of confirmed_at
118
+ if self.new_record? && self.respond_to?(:confirmation_required?)
119
+ def self.confirmation_required?; false; end
120
+ end
121
+
115
122
  generate_invitation_token if self.invitation_token.nil?
116
123
  self.invitation_sent_at = Time.now.utc
117
124
  self.invited_by = invited_by if invited_by
@@ -1,3 +1,3 @@
1
1
  module DeviseInvitable
2
- VERSION = '1.1.0'
2
+ VERSION = '1.1.1'
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: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 0
10
- version: 1.1.0
9
+ - 1
10
+ version: 1.1.1
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: 2012-08-20 00:00:00 Z
18
+ date: 2012-10-17 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: bundler
@@ -34,7 +34,7 @@ dependencies:
34
34
  type: :development
35
35
  version_requirements: *id001
36
36
  - !ruby/object:Gem::Dependency
37
- name: railties
37
+ name: actionmailer
38
38
  prerelease: false
39
39
  requirement: &id002 !ruby/object:Gem::Requirement
40
40
  none: false
@@ -49,34 +49,34 @@ dependencies:
49
49
  type: :runtime
50
50
  version_requirements: *id002
51
51
  - !ruby/object:Gem::Dependency
52
- name: actionmailer
52
+ name: devise
53
53
  prerelease: false
54
54
  requirement: &id003 !ruby/object:Gem::Requirement
55
55
  none: false
56
56
  requirements:
57
- - - ~>
57
+ - - ">="
58
58
  - !ruby/object:Gem::Version
59
- hash: 7
59
+ hash: 11
60
60
  segments:
61
- - 3
61
+ - 2
62
+ - 1
62
63
  - 0
63
- version: "3.0"
64
+ version: 2.1.0
64
65
  type: :runtime
65
66
  version_requirements: *id003
66
67
  - !ruby/object:Gem::Dependency
67
- name: devise
68
+ name: railties
68
69
  prerelease: false
69
70
  requirement: &id004 !ruby/object:Gem::Requirement
70
71
  none: false
71
72
  requirements:
72
- - - ">="
73
+ - - ~>
73
74
  - !ruby/object:Gem::Version
74
- hash: 11
75
+ hash: 7
75
76
  segments:
76
- - 2
77
- - 1
77
+ - 3
78
78
  - 0
79
- version: 2.1.0
79
+ version: "3.0"
80
80
  type: :runtime
81
81
  version_requirements: *id004
82
82
  description: It adds support for send invitations by email (it requires to be authenticated) and accept the invitation by setting a password.
@@ -94,6 +94,7 @@ files:
94
94
  - app/views/devise/invitations/new.html.erb
95
95
  - app/views/devise/mailer/invitation_instructions.html.erb
96
96
  - config/locales/en.yml
97
+ - config/locales/es.yml
97
98
  - lib/devise_invitable.rb
98
99
  - lib/devise_invitable/mailer.rb
99
100
  - lib/devise_invitable/model.rb