[英]Rails Devise, how to skip the confirmation email but still generate a confirmation token?
我正在使用
user.skip_confirmation!
在现有用户添加新用户时跳过设计电子邮件确认。 skip_confirmation的问题是它不会生成确认令牌。
我想手动发送确认电子邮件,这意味着我需要一个确认令牌。
如何跳过设计确认电子邮件但仍生成confirmmaton_token以允许我手动向添加的用户发送自定义确认电子邮件?
谢谢
@user = User.new(:email => 'email@example.com', :password => 'password')
@user.skip_confirmation_notification!
@user.save
在这里skip_confirmation_notification! 生成确认令牌但不发送确认电子邮件。
见确认.rb 。 特别是,在第253-256行附近。我认为这应该可以帮到你。
简而言之:
module Devise
module Models
module Confirmable
module ClassMethods
# Generate a token checking if one does not already exist in the database.
def confirmation_token
generate_token(:confirmation_token)
end
end
end
end
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.