我試圖顯示,當用戶無法登錄閃光警報然而,會有兩種不同的情況:Rails + Devise:自定義登錄失敗的flash消息?
由用戶輸入的電子郵件已存在,但密碼是錯誤的。我希望此消息顯示:
The email address or password you entered is incorrect.
用戶輸入的電子郵件不存在。我想這個消息顯示:
The email address and password you entered do not match our records. (You provided <span class='black'>#{params[:email]}</span>)<br/><br/> <a href='/accounts/forgot_password' class='decorate'>Having trouble accessing your account?</a>
是否有類似after_sign_in_path
在那裏我可以修改基於這些條件閃光燈鉤?
UPDATE
所以我發現了這個。但是,如何僅通過電子郵件變量傳遞not_found_in_database
?
en:
devise:
failure:
already_authenticated: "You are already signed in."
invalid: "The email address or password you entered is incorrect."
not_found_in_database: "The email address and password you entered do not match our records. (You provided <span class='black'>%{email}</span>)<br/><br/><a href='/accounts/forgot_password' class='decorate'>Having trouble accessing your account?</a>."
我正在尋找同樣的事情。初始failure.invalid和failure.not_found_in_database具有相同的消息(所以我在登錄頁面看到相同的失敗消息),這讓我認爲Devise沒有區分這兩種情況。 –