Devise - 可确认不发送电子邮件
只是为了解决这个问题:我的应用程序中确实有电子邮件。
我刚刚添加 :confirmable 到我的用户模型中。
app/models/user.rb
devise :database_authenticatable, :registerable, :omniauthable,
:recoverable, :rememberable, :trackable, :validatable, :confirmable
我确实在数据库中有可确认的部分:
db/schema.rb
create_table "users", :force => true do |t|
...
t.string "confirmation_token"
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
end
由于omniauth,我已经覆盖了registrations_controller
:
app/controllers/registrations_controller.rb
def create
super
session[:omniauth] = nil unless @user.new_record?
end
所以我想弄清楚的是......我需要添加什么才能:
在用户注册后发送确认电子邮件< /p>
将用户重定向到自定义页面,说明电子邮件正在等待确认(如果他们尝试在未确认的情况下再次登录,他们将到达该页面)(在此处回答)(应该自动处理?)当用户已验证将它们重定向到给定页面
更新:现在,当我创建用户时,它会自动确认的。这是为什么?
Just to get it out of the way: I do have emails working in my app.
I just added :confirmable to my user model.
app/models/user.rb
devise :database_authenticatable, :registerable, :omniauthable,
:recoverable, :rememberable, :trackable, :validatable, :confirmable
I do have the confirmable part in the db:
db/schema.rb
create_table "users", :force => true do |t|
...
t.string "confirmation_token"
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
end
Because of the omniauth I have overwritten registrations_controller
:
app/controllers/registrations_controller.rb
def create
super
session[:omniauth] = nil unless @user.new_record?
end
So what I'm trying to figure out is… what do I need to add in order to:
Get confirmation email sent after the user signs up
Redirect the user to a custom page explaining the email is waiting to be confirmed (which they would get to if they tried signing in again without confirming)(answered here)(should be taken care of automatically?) When the user is verified redirect them to given page
Update: Right now, when I create a user it is automatically confirmed. Why is that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,所以我没有意识到我的用户模型中有以下内容:
评论它们会发送电子邮件。仍在尝试弄清楚如果用户未确认则登录后如何重定向。并试图弄清楚如何正确使用confirmation_required?
Ok, so I didn't realize I had the following in my user model:
Commenting them out gets the email to be sent. Still trying to figure out how to redirect after sign in if the user isn't confirmed. And trying to figure out how to properly use confirmation_required?