为手动创建的用户延迟和/或重新发送 Devise 的确认电子邮件 [英] Delay and or resend Devise's confirmation email for manually created users

查看:17
本文介绍了为手动创建的用户延迟和/或重新发送 Devise 的确认电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Devise 来允许用户注册 -就像使用我自己的用户管理员手动创建用户一样.当我在管理员中创建用户时,Devise 会立即向新用户发送确认.我相信这是因为设计和我的管理员都使用相同的模型.如何延迟此电子邮件直到管理员准备好发送它?

I'm using Devise to allow user signup as-well-as using my own user admin to create users manually. When I create a user in the admin, Devise sends a confirmation immediately to the new user. I believe this is due to the fact that both devise and my admin use the same model. How do I delay this email until the administrator is ready to send it?

此外,Devise 的验证要求管理员为新用户设置密码.我更希望手动创建的用户在响应确认时指定自己的密码.现在手动创建的用户不会知道他们的密码,除非我也通过补充电子邮件将其发送给他们.

Additionally, Devise's validation is requiring the admin set a password for the new user. I would much prefer the manually created users specify their own password when they respond the confirmation. Right now manually created users will not know their password unless I send it too them in a supplemental email.

推荐答案

我们在我们的一个应用程序中执行此操作.您可以告诉 Devise 不要像这样自动发送确认:

We do this in one of our apps. You can tell Devise NOT to automatically deliver the confirmation like this:

@user.skip_confirmation!

然后,你可以做

Devise::Mailer.confirmation_instructions(@user).deliver

对于 Rails 2.x,您可以执行以下操作:

For Rails 2.x you'd do something like:

DeviseMailer.deliver_confirmation_instructions(@user)

这篇关于为手动创建的用户延迟和/或重新发送 Devise 的确认电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆