[英]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.