-
Notifications
You must be signed in to change notification settings - Fork 5.5k
How To: Allow users to edit their password
rheaton edited this page May 9, 2011
·
54 revisions
We have two options to allow users to edit their password:
- Use the registerable module, which will give you both sign up and edit user features;
- Handle your own passwords controller to allow users editing their password. Example:
class PasswordsController < ApplicationController
before_filter :authenticate_user!
def edit
@user = current_user
end
def update
@user = current_user
if @user.update_with_password(params[:user])
sign_in(@user, :bypass => true)
redirect_to root_path, :notice => "Password updated!"
else
render :edit
end
end
endIf you don't want to use update_with_password, which will require to enter the current password, see How To: Allow users to edit their account without providing a password.