recoverable: send_reset_password_instructions not setting reset_password_token

2,518 views
Skip to first unread message

ryan.drake.08

unread,
May 13, 2012, 11:00:20 AM5/13/12
to Devise
I have what I believe to be an out-of-the-box 2.0.4 devise set-up.
Everything seems to be working smoothly except for recoverable. The E-
mail delivery works, but the reset link contained within does not
contain a token, so of course the password edit operation fails. From
the rails console, executing

User.find(2).send_reset_password_instructions

...sends reset-password instructions, but the link does not contain
any token. Checking the database, it looks like the
reset_password_token field is not being set for that user.

Interestingly (again from the console),

u = User.find(2)
u.send(:generate_reset_password_token!) if
u.send(:should_generate_reset_token?)
u.devise_mailer.reset_password_instructions(u).deliver

...works fine, generating a token, saving it in the database, and
delivering it in the URL via E-mail. This is baffling, because that's
all send_reset_password_instructions looks like it should be doing.

Has anyone encountered this before, and know how to fix it?

My setup:
devise 2.0.4 (also tried 2.1.0.rc2)
rails 3.2.1
ruby 1.8.7

Carlos Antonio da Silva

unread,
May 13, 2012, 2:42:29 PM5/13/12
to plataforma...@googlegroups.com
Well, as far as I can see, this is the exact implementation of send_reset_password_instructions (https://github.com/plataformatec/devise/blob/master/lib/devise/models/recoverable.rb#L46)

      def send_reset_password_instructions
        generate_reset_password_token! if should_generate_reset_token?
        self.devise_mailer.reset_password_instructions(self).deliver
      end

So I can't see how your code would work hand the method not =(. Have you checked if reset_password_token is completely nil? (it checks for nil, not blank).

No other idea comes to my mind now.

-- 
At.
Carlos Antonio

ryan.drake.08

unread,
May 27, 2012, 6:25:11 PM5/27/12
to Devise
Thanks for the response. reset_password_token is definitely nil after
calling User.find(2).send_reset_password_instructions, but not after
manually calling the contents of send_reset_password_instructions.

I agree it's a very strange problem. I'm going to put it aside and
look at a it later.

Ryan


On May 13, 11:42 am, Carlos Antonio da Silva
<carlosantoniodasi...@gmail.com> wrote:
> Well, as far as I can see, this is the exact implementation of send_reset_password_instructions (https://github.com/plataformatec/devise/blob/master/lib/devise/models...)
Reply all
Reply to author
Forward
0 new messages