Class PasswordsController
In: app/controllers/passwords_controller.rb
Parent: ApplicationController

A controller to let a user manage their password. This controller follows the single resource design. It is always editing the password of the current user.

Methods

create   edit   new   update  

Included Modules

Login::UsernameFinder

Public Instance methods

Send forgot my password request. Basically we are starting the process of creating a new password.

[Source]

    # File app/controllers/passwords_controller.rb, line 15
15:   def create
16:     redirect_to login_url and return unless
17:       User.column_names.include? 'email'
18:     user = User.find :first, :conditions =>
19:       {username_field => params[username_field]}
20:     if user
21:       PasswordNotifications.deliver_forgot_password user, reset_link(user)
22:       flash[:notice] = 'Notice sent. Please check your email.'
23:     else
24:       flash[:warning] = 'User not found.'
25:     end
26: 
27:     redirect_to login_url
28:   end

Form to edit existing password

[Source]

    # File app/controllers/passwords_controller.rb, line 31
31:   def edit
32:     @user = current_user
33:     redirect_to login_url and return if @user.nil?
34:   end

Forgot my password form. Basically we are asking for a new password

[Source]

    # File app/controllers/passwords_controller.rb, line 9
 9:   def new
10:     redirect_to login_url unless User.column_names.include? 'email'
11:   end

Will update the current user‘s password to the given value. Will use password_confirmation if given.

[Source]

    # File app/controllers/passwords_controller.rb, line 38
38:   def update
39:     @user = current_user
40:     redirect_to login_url and return if @user.nil?
41: 
42:     @user.password = params[:user][:password]
43:     @user.password_confirmation =
44:       params[:user][:password_confirmation] if
45:       @user.respond_to? :password_confirmation
46: 
47:     if @user.save
48:       PasswordNotifications.deliver_updated_password @user,
49:         reset_link(@user) if @user.respond_to? :email
50:       flash[:notice] = 'Password successfully updated'
51:       redirect_to home_url
52:     else
53:       render :action => 'edit'
54:     end
55:   end

[Validate]