Module: DeviseBasecamper::Recoverable::ClassMethods

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

Instance Method Summary collapse

Instance Method Details

#recover_with_login?(attributes = {}) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
26
27
28
29
# File 'lib/devise-basecamper/recoverable.rb', line 23

def recover_with_login?(attributes={})
  if attributes.any?
    attributes.include?( basecamper[:login_attribute] ) && reset_password_keys.include?( basecamper[:login_attribute] )
  else
    reset_password_keys.include?( basecamper[:login_attribute] )
  end
end

#send_reset_password_instructions(attributes = {}) ⇒ Object

Override for password resets ——————-



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/devise-basecamper/recoverable.rb', line 7

def send_reset_password_instructions(attributes={})
  if recover_with_login?
    subdomain_resource                      = find_resource_by_subdomain(attributes)
    attributes[ basecamper[:scope_field] ]  = subdomain_resource.nil? ? nil : subdomain_resource.id
    recoverable                             = (reset_password_keys, attributes, :not_found)
  else
    recoverable = find_or_initialize_with_errors(reset_password_keys, attributes, :not_found)
  end

  ## Now that we have found the recoverable, we are going to call the
  ## send_reset_password_instructions on the specific recoverable
  ##
  recoverable.send_reset_password_instructions if recoverable.persisted?
  recoverable
end