【问题标题】:Issue with Devise Email Confirmation设计电子邮件确认问题
【发布时间】:2012-03-10 13:07:02
【问题描述】:

我是 Rails 新手。我第一次使用 Devise 时遇到了一些奇怪的事情。请问这是设计错误还是我的问题?

我使用的是设计 2.0.1

新用户注册后,电子邮件将发送到注册的电子邮件地址。

案例 1:

这部分没问题

一旦通过电子邮件链接确认,他就可以访问整个网站。

案例 2:

这部分不行

注册后,我没有点击确认链接,直接进入登录页面,尝试用刚刚创建的邮箱账号和密码登录,没有报错,它只是路由到登录页面。理想情况下,我希望它显示类似

的错误
"We have sent you an email. Please confirm. 
If you have not received them please ask for conformation instructions"

案例 3:

这部分不行

注册后,我点击忘记密码lnk。我输入了我刚刚注册的电子邮件地址。它会向我发送重置密码说明。而不是重置密码说明,理想情况下,我想向我发送一条错误消息"Email first has to been confirmed first in order to send reset password instructions."

期待您的帮助和支持。

谢谢

【问题讨论】:

    标签: ruby ruby-on-rails-3 authentication devise


    【解决方案1】:

    如果我需要让人们知道确认信息,我通常会在我的一个控制器中进行设置:

    render :template => 'shared/unconfirmed' and return if current_user.confirmed? == false
    

    这会阻止人们做任何事情,除非他们已经确认,并且限制要求决定了我把它放在哪里。例如,如果你想阻止人们做所有事情,直到他们确认,把它放在你的 application_controller 的 before_filter 中。如果您希望他们停止创建帖子,请将其放在帖子控制器中。

    为此,您还应该更改 devise.rb 配置文件中“config.confirm_within”设置的默认值,以让人们进入:

    # ==> Configuration for :confirmable
    # A period that the user is allowed to access the website even without
    # confirming his account. For instance, if set to 2.days, the user will be
    # able to access the website for two days without confirming his account,
    # access will be blocked just in the third day. Default is 0.days, meaning
    # the user cannot access the website without confirming his account.
    # config.confirm_within = 2.days
    

    【讨论】:

    • 我试过这样做..但我收到一个错误!另外,我不想首先给用户 2 天的访问权限。我更关注的是 Devise Bug.. 上面提到的案例 3 和案例 2..
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-12-22
    • 2011-08-22
    • 1970-01-01
    • 2019-08-04
    • 1970-01-01
    • 2012-09-03
    • 1970-01-01
    相关资源
    最近更新 更多