简体   繁体   中英

How to create a link that lets the user Reset Their Password when Signed In with Devise?

With devise, if you navigate to the reset your password link, it only shows the view if you are signed in.

For signed in users, I would like to provide them with a link to "reset their password" - Anyone know if this is possible, how?

Thanks

If you run rake routes you'll see 2 relevant paths: edit_user_password and edit_user_registration .

edit_user_password is for users who would like to reset their password, but are not signed in, via a reset token.

edit_user_registration is used to edit the current user's information, including resetting his or her password , when the user is signed in. If you'd like to customize this further, ensure that you've generated the devise views: rails generate devise:views , see "Configuring views" here ). The corresponding view in this case is devise/registrations/edit.html.erb .

Good luck!

<%= link_to "Sign up", new_user_registration_path %>
<%= link_to "Sign in", new_user_session_path %>
<%= link_to "Sign out", destroy_user_session_path %>
<%= link_to "Edit settings", edit_user_password %>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM