lib/mailkick.rb in mailkick-0.3.0 vs lib/mailkick.rb in mailkick-0.3.1
- old
+ new
@@ -89,11 +89,13 @@
def self.message_verifier
@message_verifier ||= ActiveSupport::MessageVerifier.new(Mailkick.secret_token)
end
- def self.generate_token(email, list: nil)
- user = Mailkick.user_method.call(email) if Mailkick.user_method
+ def self.generate_token(email, user: nil, list: nil)
+ raise ArgumentError, "Missing email" unless email
+
+ user ||= Mailkick.user_method.call(email) if Mailkick.user_method
message_verifier.generate([email, user.try(:id), user.try(:class).try(:name), list])
end
end
ActiveSupport.on_load(:active_record) do