I am trying to implement "Forgot Password" functionality using "devise_token_auth" in Rails 5 api, in which I have carried out the following steps:
Hit the "localhost:3000/auth/password" with registered users email, redirect_url as parameters. I got the email as well.
When clicking the "change my password" link in the mail, it redirects to "localhost:3000/api/auth/password/edit/..." instead of "localhost:3000/auth/password/edit/..."
My reset_password_instructions.html.erb is as follows:
<p><%= t(:hello).capitalize %> <%= @resource.email %>!</p>
<p><%= t '.request_reset_link_msg' %></p>
<p><%= link_to t('.password_change_link'), edit_password_url(@resource, reset_password_token: @token, config: message['client-config'].to_s, redirect_url: message['redirect-url'].to_s).html_safe %></p>
<p><%= t '.ignore_mail_msg' %></p>
<p><%= t '.no_changes_msg' %></p>
I am not able to figure out how "edit_password_url" resolves to "localhost:3000/api/auth/password/edit/..." instead of "localhost:3000/auth/password/edit/...". Could anyone be able to help me here?
Note: In development.rb, I have config.action_controller.default_url_options = { host: 'localhost:3000' }
UPDATE:
Routes.rb
Rails.application.routes.draw do
#.....
resources :employee_contact_infos
resources :employee_work_infos
mount_devise_token_auth_for 'User', at: 'auth'
# get '/api' => redirect('/swagger/dist/index.html?url=/apidocs/api-docs.json')
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
get '/industry_sectors' => 'drop_down_values#industry_sector_list'
get '/currencies' => 'drop_down_values#currency'
#...
namespace :employees do
end
end
rake routes output for devise_token_auth:
new_user_session GET /auth/sign_in(.:format) devise_token_auth/sessions#new
user_session POST /auth/sign_in(.:format) devise_token_auth/sessions#create
destroy_user_session DELETE /auth/sign_out(.:format) devise_token_auth/sessions#destroy
new_user_password GET /auth/password/new(.:format) devise_token_auth/passwords#new
edit_user_password GET /auth/password/edit(.:format) devise_token_auth/passwords#edit
user_password PATCH /auth/password(.:format) devise_token_auth/passwords#update
PUT /auth/password(.:format) devise_token_auth/passwords#update
POST /auth/password(.:format) devise_token_auth/passwords#create
cancel_user_registration GET /auth/cancel(.:format) devise_token_auth/registrations#cancel
new_user_registration GET /auth/sign_up(.:format) devise_token_auth/registrations#new
edit_user_registration GET /auth/edit(.:format) devise_token_auth/registrations#edit
user_registration PATCH /auth(.:format) devise_token_auth/registrations#update
PUT /auth(.:format) devise_token_auth/registrations#update
DELETE /auth(.:format) devise_token_auth/registrations#destroy
POST /auth(.:format) devise_token_auth/registrations#create
auth_validate_token GET /auth/validate_token(.:format) devise_token_auth/token_validations#validate_token
Swagger_docs.rb
class Swagger::Docs::Config
def self.base_api_controller; ApplicationController end
def self.transform_path(path, api_version)
# Make a distinction between the APIs and API documentation paths.
"#{path}"
end
Swagger::Docs::Config.register_apis({
'1.0' => {
controller_base_path: '',
api_file_path: 'public/apidocs',
base_path: 'http://localhost:3000',
clean_directory: true
}
})
end
rake routes- arieljuodedit_user_password_url, notedit_password_url. And I see no reference to/apianywhere neither on the routes.rb or the rake routes output. What do you get if you runrake routes | grep 'api'? - arieljuod