[英]Rails Devise, how to skip the confirmation email but still generate a confirmation token?
I'm using 我正在使用
user.skip_confirmation!
To skip the devise email confirmation when a new user is added by an existing user. 在现有用户添加新用户时跳过设计电子邮件确认。 The problem with the skip_confirmation is that it does not generate a confirmation token. skip_confirmation的问题是它不会生成确认令牌。
I want to manually send a confirmation email which means I need a confirmation token. 我想手动发送确认电子邮件,这意味着我需要一个确认令牌。
How can I skip the devise confirmation email yet still generate a confirmaton_token to allow me to manually send a custom confirmation email to added users? 如何跳过设计确认电子邮件但仍生成confirmmaton_token以允许我手动向添加的用户发送自定义确认电子邮件?
Thanks 谢谢
@user = User.new(:email => 'email@example.com', :password => 'password')
@user.skip_confirmation_notification!
@user.save
Here skip_confirmation_notification! 在这里skip_confirmation_notification! generate a confirmation token but does not send confirmation email. 生成确认令牌但不发送确认电子邮件。
See confirmable.rb . 见确认.rb 。 In particular, around line 253 - 256. I think that should help you out. 特别是,在第253-256行附近。我认为这应该可以帮到你。
In short: 简而言之:
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.