簡體   English   中英

設計添加到密碼更改

[英]Devise add to password change

我想在用戶更改密碼后為用戶更改一個簡單的屬性。

我為用戶提供了一個名為“ password_changed”的屬性,默認值為false,但他們希望在更改密碼后將其更改為true。 這是創建自定義Devise密碼編輯的唯一方法嗎? 像這樣( https://github.com/plataformatec/devise/wiki/How-To:-Allow-users-to-edit-their-password )。 或者可以使用以下方法擴展devise注冊控制器上的update方法:

def update
current_user.password_changed = true
current_user.save
end

您可以為User模型使用after_save回調:

after_save :password_changed_callback, if: Proc.new { |record| record.persisted? && record.password_changed? }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM