【发布时间】:2014-04-02 19:04:05
【问题描述】:
我正在尝试实现设计的自动锁定功能。我的应用程序仍在开发中。我输入了错误的密码来激活自动锁定功能,并且工作正常,但我在设置电子邮件以解锁帐户时遇到了问题。
在 config/environments/development.rb 我有:
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
在 config/initializers/devise.rb 我有
config.mailer_sender = 'sender@mail.com'
config.mailer = 'Devise::Mailer'
然后在同一个文件中进一步向下:
# ==> Configuration for :lockable
# Defines which strategy will be used to lock an account.
# :failed_attempts = Locks an account after a number of failed attempts to sign in.
# :none = No lock strategy. You should handle locking by yourself.
config.lock_strategy = :failed_attempts
# Defines which key will be used when locking and unlocking an account
config.unlock_keys = [ :email ]
# Defines which strategy will be used to unlock an account.
# :email = Sends an unlock link to the user email
# :time = Re-enables login after a certain amount of time (see :unlock_in below)
# :both = Enables both strategies
# :none = No unlock strategy. You should handle unlocking by yourself.
config.unlock_strategy = :email
# Number of authentication tries before locking an account if lock_strategy
# is failed attempts.
config.maximum_attempts = 5
# Time interval to unlock the account if :time is enabled as unlock_strategy.
# config.unlock_in = 1.hour
# Warn on the last attempt before the account is locked.
config.last_attempt_warning = true
# ==> Configuration for :recoverable
#
# Defines which key will be used when recovering the password for an account
config.reset_password_keys = [ :email ]
# Time interval you can reset your password with a reset password key.
# Don't put a too small interval or your users won't have the time to
# change their passwords.
config.reset_password_within = 6.hours
根据我的服务器日志,电子邮件已发送。我看到以下内容:
Sent mail to receiver@mail.com (48.3ms)
Date: Wed, 02 Apr 2014 11:25:41 +0100
From: sender@mail.com
Reply-To: sender@mail.com
To: receiver@mail.com
Message-ID: <533be5a583e8d_9b624e20d76904fc@ubuntuSheeka.mail>
Subject: Unlock Instructions
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
<p>Hello receiver@mail.com!</p>
<p>Your account has been locked due to an excessive number of unsuccessful sign in attempts.</p>
<p>Click the link below to unlock your account:</p>
<p><a href="http://localhost:3000/users/unlock?unlock_token=yQS9XYp4twxGr1TXMywx">Unlock my account</a></p>
问题是我没有在收件箱中看到邮件。对此的任何帮助将不胜感激。
【问题讨论】:
标签: ruby-on-rails devise