summaryrefslogtreecommitdiff
path: root/app/controllers/passwords_controller.rb
blob: 988ede3007bcde76b39f4754d9e94d412ef6d32d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class PasswordsController < Devise::PasswordsController

  def create
    email = resource_params[:email]
    resource_found = resource_class.find_by_email(email)
    if resource_found && resource_found.ldap_user?
      flash[:alert] = "Cannot reset password for LDAP user."
      respond_with({}, :location => after_sending_reset_password_instructions_path_for(resource_name)) and return
    end

    self.resource = resource_class.send_reset_password_instructions(resource_params)
    if successfully_sent?(resource)
      respond_with({}, :location => after_sending_reset_password_instructions_path_for(resource_name))
    else
      respond_with(resource)
    end
  end
end