ユーザーが古いパスワードを知っている場合にのみパスワードを更新できるようにしたいと考えています。現在、ユーザーが古いパスを確認せずにパスワードを更新できるようにしています。正しい方向に私を向けることができますか。
現在のユーザーの更新方法:
def update
if params[:user][:password]
if current_user
@user = User.find(params[:id])
if @user.update_attributes(params[:user])
redirect_to root_url, :notice => "Password has been changed!"
else
render "edit"
end
else
# Something else
end
end
end
(HAML) 現在の形式:
= form_for @user do |f|
- if @user.errors.any?
- for message in @user.errors.full_messages
= message
.form
= f.password_field :password
= f.password_field :password_confirmation
%input{name: "commit", type: "submit", value: "SAVE CHANGES"}