user4311043
user4311043

Reputation:

Devise account confirmation link does not work

I updated Devise gem from 2.2.3 -> 3.2. everything else works fine but Account confirmation link sent as email does not work fine.

When User click on that link it always ask the user to resend confirmation link and it never confirms the account.

I checked the stored confirmation token in User table and the confirmation token sent as email both are same but still does not work.

Here is my mailer code for account confirmation.

<p>Welcome <%= @email %>!</p>

<p>You can confirm your account email through the link below:</p>

<p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %></p>

Upvotes: 4

Views: 1289

Answers (1)

Qaisar Nadeem
Qaisar Nadeem

Reputation: 2434

According to this blog you need to change your Devise mailer to use @token instead of the old @resource.confirmation_token.

This should fix any token-based confirmation problems you're having. This is likely to fix any unlock or reset password token problems as well. Here is your mailer updated code

<p>Welcome <%= @email %>!</p>

<p>You can confirm your account email through the link below:</p>

<p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @token) %></p>

Upvotes: 3

Related Questions