Upgrading to devise 3.1 => getting Reset password token is invalid

前端 未结 6 2310
隐瞒了意图╮
隐瞒了意图╮ 2020-12-15 02:53

Solution

Thanks to this gist form Steven Harman, I got it working. devise_mail_helpers.rb

module Features
  module MailHelpers

             


        
6条回答
  •  情书的邮戳
    2020-12-15 03:34

    FYI, if you're trying to send a reset password token via another means (i.e. different mailer), you can use code like this (dug out of Devise source), in your User class:

    def send_invitation
      raw, enc = Devise.token_generator.generate(self.class, :reset_password_token)
    
      self.reset_password_token   = enc
      self.reset_password_sent_at = Time.now.utc
      self.save(:validate => false)
    
      Notifier.signup_notification(contactable: self, token: raw).deliver
    end
    

提交回复
热议问题