首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >由于无效的电子邮件或密码在rails中不起作用而导致Devise登录错误

由于无效的电子邮件或密码在rails中不起作用而导致Devise登录错误
EN

Stack Overflow用户
提问于 2016-05-20 15:48:52
回答 2查看 2.5K关注 0票数 0

我有一个很棒的user模型。当user输入错误的password并通过显示无效的电子邮件或密码重定向回登录页面时,这是正常工作的。但是,当用户输入错误的email时,我不会得到相同的错误。我得到了一个不同的error

代码语言:javascript
复制
I18n::MissingInterpolationArgument at /users/sign_in
missing interpolation argument :authentication_keys in "Invalid %{authentication_keys} or password." ({:resource_name=>:user} given)

。在我的用户模型中,我有一个用户名字段(这是唯一的)。在我的例子中,用户可以同时使用usernameemail登录。这个customisation产生了什么问题吗?这是我的devise.en.yml文件。

代码语言:javascript
复制
# Additional translations at https://github.com/plataformatec/devise/wiki/I18n

en:
  devise:
    confirmations:
      confirmed: "Your email address has been successfully confirmed."
      send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes."
      send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes."
    failure:
      already_authenticated: "You are already signed in."
      inactive: "Your account is not activated yet."
      invalid: "Invalid email or password."
      locked: "Your account is locked."
      last_attempt: "You have one more attempt before your account is locked."
      not_found_in_database: "Invalid %{authentication_keys} or password."
      timeout: "Your session expired. Please sign in again to continue."
      unauthenticated: "You need to sign in or sign up before continuing."
      unconfirmed: "You have to confirm your email address before continuing."
    mailer:
      confirmation_instructions:
    subject: "Confirmation instructions"
      reset_password_instructions:
    subject: "Reset password instructions"
      unlock_instructions:
    subject: "Unlock instructions"
      password_change:
    subject: "Password Changed"
    omniauth_callbacks:
      failure: "Could not authenticate you from %{kind} because \"%{reason}\"."
      success: "Successfully authenticated from %{kind} account."
    passwords:
      no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
      send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes."
      send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
      updated: "Your password has been changed successfully. You are now signed in."
      updated_not_active: "Your password has been changed successfully."
    registrations:
      destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon."
      signed_up: "Welcome! You have signed up successfully."
      signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated."
      signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked."
      signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account."
      update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirm link to confirm your new email address."
      updated: "Your account has been updated successfully."
    sessions:
      signed_in: "Signed in successfully."
      signed_out: "Signed out successfully."
      already_signed_out: "Signed out successfully."
    unlocks:
      send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes."
      send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes."
      unlocked: "Your account has been unlocked successfully. Please sign in to continue."
  errors:
    messages:
      already_confirmed: "was already confirmed, please try signing in"
      confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
      expired: "has expired, please request a new one"
      not_found: "not found"
      not_locked: "was not locked"
      not_saved:
    one: "1 error prohibited this %{resource} from being saved:"
    other: "%{count} errors prohibited this %{resource} from being saved:"

这些是gemfile.lock文件中的devise和rails版本。

代码语言:javascript
复制
    devise (3.2.4)
    devise-async (0.9.0)
    devise (~> 3.2)
    devise
    devise-async

    rails (4.1.5)
EN

回答 2

Stack Overflow用户

发布于 2016-05-20 17:43:06

例如,您需要在用户模型中定义一个名为login的虚拟属性,并告诉devise在authentication_keys中使用此字段。

有关详细信息https://github.com/plataformatec/devise/wiki/How-To:-Allow-users-to-sign-in-using-their-username-or-email-address,请查看此链接

票数 0
EN

Stack Overflow用户

发布于 2016-08-04 03:09:16

我遇到了同样的问题,我通过更新到最新版本的devise (我目前运行的是4.2.0)解决了这个问题。您可能需要更新您的ruby版本才能使用最新版本的devise。(https://github.com/plataformatec/devise/blob/master/CHANGELOG.md#400rc1---2016-02-01)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37340962

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档