An application I inherited has the following action for updating a user's profile:
class UsersController < ApplicationController
# ...
def update
@user = current_user
if @user.update_attributes(params[:user])
flash[:notice] = "Successfully updated profile."
redirect_to root_url
else
flash[:error] = "Hrm, something went wrong."
render :action => 'edit'
end
end
end
The form that PUT
s (really POST
s with a _method=PUT
) to that action has a password
and password_confirmation
field, but no old_password
field. I've noticed through testing that I don't even have to fill in the password_confirmation
field.
First question: is there a more established way of doing a password change when using Authlogic?
Second question: is there any literature on best practices (especially from a usability standpoint) on password-changes? Should it be a separate form, not mixed in with other user fields?
Third question: Most sites have an old_password
field, but Authlogic doesn't seem to support that natively. What's the Authlogic-ey way of confirming it's actually the user him/herself changing the password rather than somebody who has hacked their session?