Module: Devise::Models::Basecamper::ClassMethods

Defined in:
lib/devise-basecamper/model.rb

Instance Method Summary collapse

Instance Method Details

#basecamperObject



17
18
19
20
# File 'lib/devise-basecamper/model.rb', line 17

def basecamper
  self.devise_basecamper if @devise_basecamper_settings.nil?
  return @devise_basecamper_settings
end

#devise_basecamper(opts = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/devise-basecamper/model.rb', line 7

def devise_basecamper(opts={})
  defaults = {
    :subdomain_class  => :account,
    :subdomain_field  => :subdomain,
    :scope_field      => :account_id,
    :login_fields     => [:username, :email]
  }
  @devise_basecamper_settings = defaults.merge(opts)
end

#find_for_authentication(conditions = {}) ⇒ Object

Methods ————————————————————



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/devise-basecamper/model.rb', line 24

def find_for_authentication(conditions={})
  authentication_keys = Devise.authentication_keys

  ## Process subdomain info by finding the parent resource id into the conditions
  conditions = clean_conditions_for_subdomain(conditions)

  ## Process if "login" key used instead of default (:email)
  if conditions[:login].present? && authentication_keys.include?(:login)
    resource = ( authentication_keys, conditions )
    return resource
  end

  ## Execute original find_for_authentication code
  super
end

#send_confirmation_instructions(attributes = {}) ⇒ Object



50
51
52
# File 'lib/devise-basecamper/model.rb', line 50

def send_confirmation_instructions(attributes={})
  send_instructions_for(:confirmation, attributes)
end

#send_reset_password_instructions(attributes = {}) ⇒ Object

TODO: Probably should break this out or atleast put some conditions in place so that this method is only included when “RECOVERABLE” is a specified option for the resource.

We want to override this method to find our users within the scope of our subdomain.



46
47
48
# File 'lib/devise-basecamper/model.rb', line 46

def send_reset_password_instructions(attributes={})
  send_instructions_for(:reset_password, attributes)
end