Class: PasswordsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/passwords_controller.rb

Constant Summary collapse

PUBLIC_ACTIONS =

For logmein integration. If you are not using logmein you need to ensure your authentication system allows access to these actions without being authenticated.

%w(new create edit update)

Instance Method Summary collapse

Instance Method Details

#createObject


8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/passwords_controller.rb', line 8

def create
  authenticated_record = klass.find_by_email params[:email]
  if authenticated_record
    authenticated_record.reset_perishable_token!
    PasswordMailer.default_url_options[:host] = request.host
    PasswordMailer.default_url_options[:port] = request.port
    PasswordMailer.password_reset_instructions(authenticated_record, request).deliver
  else
    flash.now[:warning] = 'That e-mail was not found'
    render :action => 'new'
  end
end

#updateObject


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

def update
  @authenticated_record.password = params[:authenticated_record][:password]
  @authenticated_record.password_confirmation = params[:authenticated_record][:password_confirmation]
  if @authenticated_record.save
    next_url = session[:return_to] || send(Remindme.final_destination)
    flash[:notice] = "Password successfully updated"
    # Go ahead an log the user in in case the redirect is to a restricted page
    klass.session_class.create! @authenticated_record
    session.delete :return_to
    redirect_to next_url
  else
    render :action => :edit
  end
end