devise-basecamper 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,22 +2,22 @@ module Devise
2
2
  module Models
3
3
  module Basecamper
4
4
  extend ActiveSupport::Concern
5
-
5
+
6
6
  module ClassMethods
7
7
  def devise_basecamper(opts={})
8
8
  defaults = {
9
9
  :subdomain_class => :account,
10
10
  :subdomain_field => :subdomain,
11
- :scope_field => :account_id
11
+ :scope_field => :account_id
12
12
  }
13
13
  @devise_basecamper_settings = defaults.merge(opts)
14
14
  end
15
-
15
+
16
16
  def basecamper
17
17
  self.devise_basecamper if @devise_basecamper_settings.nil?
18
18
  return @devise_basecamper_settings
19
19
  end
20
-
20
+
21
21
  def find_for_authentication(conditions={})
22
22
  if conditions[:subdomain].present?
23
23
  resource = self.basecamper[:subdomain_class].to_s.camelize.constantize
@@ -27,6 +27,20 @@ module Devise
27
27
  end
28
28
  super
29
29
  end
30
+
31
+ # TODO: Probably should break this out or atleast put some conditions in place
32
+ # so that this method is only included when "RECOVERABLE" is a specified option
33
+ # for the resource.
34
+ #
35
+ # We want to override this method to find our users within the scope
36
+ # of our subdomain.
37
+ def send_reset_password_instructions(attributes={})
38
+ resource = self.basecamper[:subdomain_class].to_s.camelize.constantize
39
+ subdomain_source = resource.to_adapter.find_first(self.basecamper[:subdomain_field] => attributes[:subdomain])
40
+ recoverable = find_or_initialize_with_errors([self.basecamper[:scope_field], :email], { :email => attributes[:email], self.basecamper[:scope_field] => (subdomain_source.nil? ? nil : subdomain_source.id.to_s) })
41
+ recoverable.send_reset_password_instructions if recoverable.persisted?
42
+ recoverable
43
+ end
30
44
  end
31
45
  end
32
46
  end
@@ -1,5 +1,5 @@
1
1
  module Devise
2
2
  module Basecamper
3
- VERSION = "0.1.3"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise-basecamper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-30 00:00:00.000000000 Z
12
+ date: 2012-09-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: orm_adapter
@@ -73,12 +73,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
73
73
  - - ! '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
+ segments:
77
+ - 0
78
+ hash: -987934111135055412
76
79
  required_rubygems_version: !ruby/object:Gem::Requirement
77
80
  none: false
78
81
  requirements:
79
82
  - - ! '>='
80
83
  - !ruby/object:Gem::Version
81
84
  version: '0'
85
+ segments:
86
+ - 0
87
+ hash: -987934111135055412
82
88
  requirements: []
83
89
  rubyforge_project:
84
90
  rubygems_version: 1.8.24