public
Description: The open source social networking platform in Ruby on Rails from the author of RailsSpace
Homepage: http://insoshi.com
Clone URL: git://github.com/insoshi/insoshi.git
Search Repo:
insoshi / app / controllers / password_reminders_controller.rb
100644 33 lines (27 sloc) 0.722 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
class PasswordRemindersController < ApplicationController
 
  before_filter :check_can_send_email
  
  def new
  end
  
  def create
    person = Person.find_by_email(params[:person][:email])
    respond_to do |format|
      format.html do
        if person.nil?
          flash.now[:error] = "Invalid email address"
          render :action => "new"
        else
          PersonMailer.deliver_password_reminder(person)
          flash[:success] = "Your password has been sent"
          redirect_to login_url
        end
      end
    end
  end
 
  private
  
    def check_can_send_email
      unless global_prefs.can_send_mail?
        flash[:error] = "Invalid action"
        redirect_to home_url
      end
    end
end