Skip to main content

How do I get e-mailed password change and confirmation links working with devise-token-auth and ng-token-auth?

Rails • Asked by Robert King

I am trying to use ng-token-auth (Angular 1) on a separate frontend to allow passwords to be reset and account e-mail addresses to be confirmed on a Ruby on Rails 5.0 backend.

Whenever I request a password reset I get the following kind of link back:

http://localhost:8080/?client_id=<client_id>&config=default&expiry=<expiry_stamp>reset_password=true&token=<token>&uid=<email address>#/reset-password

Instead of getting the #/reset-password before the query string like below, it keeps getting added onto the end and messing up when it does the redirect. When it lands on the reset-password ui state, the controller for that state cant operate correctly.

In app/views/devise/mailer/reset_password_instructions.html.erb I have the following template code:

    <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>

Inside of my app.js on the frontend, I am configuring $authProvider with the following:

   function AuthSetup($authProvider) {
     $authProvider.configure({
      apiUrl: 'http://localhost:3000',
      passwordResetSuccessUrl: 'http://localhost:8080/#/reset-password'
    });
   }

I would greatly appreciate any help or guidance anyone could offer. Thanks.


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 27,623+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.