我的应用程序正在使用 Devise,并且正确发送确认电子邮件,并在用户单击确认链接后正确确认用户。我还想在用户确认后发送第二封电子邮件。
关于如何延迟确认或两步确认有很多建议,但没有关于我正在寻找的内容(我可以找到)。
Devise::Module::Confirmable 文档告诉我要使用的方法是确认!,但我不确定如何执行此操作。有任何想法吗?
Rails 设计:after_confirmation https://stackoverflow.com/questions/4558463/rails-devise-after-confirmation
只需定义一个 after_save 回调来检查用户是否已确认,如果是,则发送电子邮件。
如果您想节省一些 CPU 周期,您可以使用如下内容覆盖 Devise ConfirmationsController:
class ConfirmationsController < Devise::ConfirmationsController
def show
self.resource = resource_class.confirm_by_token(params[:confirmation_token])
if resource.errors.empty?
set_flash_message(:notice, :confirmed) if is_navigational_format?
sign_in(resource_name, resource)
# Send the user a second email
send_post_confirmation_email
respond_with_navigational(resource){ redirect_to after_confirmation_path_for(resource_name, resource) }
else
respond_with_navigational(resource.errors, :status => :unprocessable_entity){ render :new }
end
end
end
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)