简体   繁体   中英

Devise Password Reset Error

I have devise set up in my application and when i try to reset my password it generates these two URLs out of which only the first one works fine.

http://<domain>/password/edit?reset_password_token=SawsfhnpFRPHsxj_HjRhJ <--- works
http://<domain>/users/password/edit?reset_password_token=o1x1wFjQZxWnAug7K1zo

Any way to make sure it generates the right URL when a user wants to reset the password?

Routes

# Devise Authentication
  devise_for :users, :controllers => { :registrations => "registrations", :sessions => "sessions" },
                                        :path => "",
                                        :path_names => { :sign_in => 'login',
                                                         :sign_out => 'logout',
                                                         :sign_up => 'signup',
                                                         :edit => 'profile/edit' }

  devise_scope :user do
    match '/update_password' => 'registrations#update_password', via: :post
  end

app/views/users/mailer/reset_password_instructions.html.erb

<p><%= link_to 'Click here', edit_password_url(@resource, reset_password_token: @token) %> to reset your password</p>

When i rake routes i am not finding the above routes.

Found these routes

user_password POST   /password(.:format)                                             devise/passwords#create
                                   new_user_password GET    /password/new(.:format)                                         devise/passwords#new
                                  edit_user_password GET    /password/edit(.:format)                                        devise/passwords#edit
                                                     PATCH  /password(.:format)                                             devise/passwords#update
                                                     PUT    /password(.:format)                                             devise/passwords#update

Keep it inside the devise_for scope

devise_for :users, :controllers => { :registrations => "registrations", :sessions => "sessions" },
                                    :path => "",
                                    :path_names => { :sign_in => 'login',
                                                     :sign_out => 'logout',
                                                     :sign_up => 'signup',
                                                     :edit => 'profile/edit' } do
  match '/update_password' => 'users/registrations#update_password', via: :post
end

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