Rajdeep Singh
Rajdeep Singh

Reputation: 17834

Override PasswordsController in Devise to change password when the user is already signed in

I want to add a feature to my app in which when a user is signed in he can change his password just by clicking on change password link.But when I click on that link it redirects to the current page.

<%= link_to 'Change password', edit_user_password_path %>

Can someone tell me what to do to solve this problem?

Upvotes: 0

Views: 158

Answers (2)

vitdes
vitdes

Reputation: 124

Assuming user is loged in and want to change his password

Devise::RegistrationsController#edit

Your link would like:

<%= link_to 'Change password', edit_user_registration_path(current_user) %>

Upvotes: 1

pmuens
pmuens

Reputation: 798

Because I can't write a comment (my reputation is too low) I'll write an answer instead.

Take a look here:

rails devise edit_user_password_path

This should solve your problem.

In short: The Devise PasswordsController can only be used if a user is signed_out.

Upvotes: 1

Related Questions