我想自定义
如果您在没有reset_password_token作为查询字符串参数的情况下提交用户/密码/编辑,则会发生重置密码令牌不能为空
验证错误。此验证不在devise.en.yml
中,我找不到在Devise的源中声明验证器的位置。有可能吗?
答案 0 :(得分:4)
重置密码令牌错误应该只是一个标准属性reset_password_token
,其密钥为blank
,它存储在您嵌入Devise的模型中。假设您的类名为User且您正在使用ActiveRecord,这应该工作:
en:
activerecord:
attributes:
user:
reset_password_token: Password token
errors:
models:
user:
attributes:
reset_password_token:
blank: was not found
应该为您提供“未找到密码令牌”作为错误消息。
答案 1 :(得分:-2)
我将它从宝石中取出并放入config/locales
en:
errors:
messages:
not_found: "not found"
already_confirmed: "was already confirmed"
not_locked: "was not locked"
devise:
failure:
unauthenticated: 'You need to sign in or sign up before continuing.'
unconfirmed: 'You have to confirm your account before continuing.'
locked: 'Your account is locked.'
invalid: 'Invalid email or password.'
invalid_token: 'Invalid authentication token.'
timeout: 'Your session expired, please sign in again to continue.'
inactive: 'Your account was not activated yet.'
sessions:
signed_in: 'Signed in successfully.'
signed_out: 'Signed out successfully.'
passwords:
send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.'
updated: 'Your password was changed successfully. You are now signed in.'
confirmations:
send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.'
confirmed: 'Your account was successfully confirmed. You are now signed in.'
registrations:
signed_up: 'You have signed up successfully. If enabled, a confirmation was sent to your e-mail.'
updated: 'You updated your account successfully.'
destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.'
unlocks:
send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.'
unlocked: 'Your account was successfully unlocked. You are now signed in.'
mailer:
confirmation_instructions:
subject: 'Confirmation instructions'
reset_password_instructions:
subject: 'Reset password instructions'
unlock_instructions:
subject: 'Unlock Instructions'