我有一個自定義控制器,可以根據代碼here處理用戶密碼的編輯。設計不驗證密碼/密碼確認
用戶模型
attr_accessible :password, :password_confirmation, :username, :login
...
devise :database_authenticatable,
:lockable,
:registerable,
:recoverable,
:rememberable,
:trackable
PasswordsController
expose(:user) { current_user }
def update
if user.update_with_password(params[:user])
sign_in(user, :bypass => true)
flash[:notice] = "success"
else
render :edit
end
end
我改密碼錶單位於here。
問題是無論我輸入什麼(或不輸入該事項)到編輯密碼錶單中,都會顯示「成功」閃存方法。
是否所有的工作,但它應該如何?如果確認字段不匹配或者current_password錯誤,它不會更改密碼? – Dex
它仍會將其更改爲:無論密碼如何(如果有的話)都在:password_confirmation中。 –
如果將if語句更改爲'if params [:user] [:password] == params [:user] [:password_confirmation]'並將'user.update_with_password(params [:user])''更改爲body ? –