Ask A Question


You’re not receiving notifications from this thread.

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

Robert King asked in Rails

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 %> <%= %>!</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) {
      apiUrl: 'http://localhost:3000',
      passwordResetSuccessUrl: 'http://localhost:8080/#/reset-password'

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

Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 81,149+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more.

    © 2024 GoRails, LLC. All rights reserved.