Module: Clearance::App::Controllers::PasswordsController::Actions

Defined in:
lib/clearance/app/controllers/passwords_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/clearance/app/controllers/passwords_controller.rb', line 21

def create
  if user = User.find_by_email(params[:password][:email])
    user.forgot_password!
    ClearanceMailer.deliver_change_password user
    flash[:notice] = "You will receive an email within the next few minutes. " <<
                     "It contains instructions for changing your password."
    redirect_to url_after_create
  else
    flash.now[:notice] = "Unknown email"
    render :action => :new
  end
end

#editObject



34
35
36
# File 'lib/clearance/app/controllers/passwords_controller.rb', line 34

def edit
  @user = User.find_by_id_and_token(params[:user_id], params[:token])
end

#newObject



18
19
# File 'lib/clearance/app/controllers/passwords_controller.rb', line 18

def new
end

#updateObject



38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/clearance/app/controllers/passwords_controller.rb', line 38

def update
  @user = User.find_by_id_and_token(params[:user_id], params[:token])

  if @user.update_password(params[:user][:password], 
                           params[:user][:password_confirmation])
    @user.confirm_email! unless @user.email_confirmed?
    sign_user_in(@user)
    redirect_to url_after_update
  else
    render :action => :edit
  end
end