Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-written URL with token does not work with Angular default routing #599

Closed
vjwilson opened this issue Apr 6, 2016 · 5 comments
Closed

Comments

@vjwilson
Copy link

vjwilson commented Apr 6, 2016

We are using devise-token-auth with ng-token auth, and we have set a custom URL for the password reset:

    passwordResetSuccessUrl: location.protocol + '//' + location.host + '/#/reset-password'

The way devise-token-auth breaks apart and re-builds the URL to include the token during the password reset process causes our Angular app to show a weird URL once a person is logged in after resetting the password. The Angular fragment identifier is at the end, after the token in the query string.

For example,

    http://localhost:8000/?token=asdklfadsoeruqwieuy84vbzxnmczmxbnxzbvxzcasdkjlhfaj#/reset-password

The current code that does it this way is at https://github.com/lynndylanhurley/devise_token_auth/blob/15bf7857eca2d33602c7a9cb9d08db8a160f8ab8/lib/devise_token_auth/url.rb

It looks like it was changed at one point to work with Angular routing, b367d67, but then it was changed to the current form later because of an iOS issue, #213

I know that the current form adheres to the HTML spec. I also know that switching to the HTML5 routing in Angular effectively circumvents this issue, because we have another Angular app with a similar setup which uses HTML5 routing, and that works as expected. However, we are not able to switch the first app to HTML5 routing for other reasons.

Both apps use the same Rails API, and as a workaround we have overridden the devise-token-auth's password controller edit method, to sniff out URLs with fragment at the end, and rewrite them the old way. This is hacky, though.

It looks like this issue has come up before, #321, but it seems that the reporter in that case decided to solve it by not overriding the password reset URL.

Is there a possibility that the library could be made rewrite the URLs based on whether it needed iOS or Angular style?

@rasmar
Copy link

rasmar commented Jun 12, 2017

I've bumped on the same issue. Workaround is to use pretty urls in Angular.

Reference:
https://scotch.io/tutorials/pretty-urls-in-angularjs-removing-the-hashtag#toc-setting-for-relative-links

EDIT: Seen Your comment about HTML5. You're right. This issue should be patched. Old way worked like a charm.

@zachfeldman
Copy link
Contributor

@rachuxx feel free to submit a PR! Closing for now due to a proposed workaround.

@array42-zz
Copy link

Unfortunately we do depend upon the old URL-Schema of Angular. We can't just change to HTML5 Routes, so this Workaround does not apply. Pls reopen.

@zachfeldman
Copy link
Contributor

Hi @array42 , I'm glad to reopen if you submit a pull request for your problem.

@array42-zz
Copy link

Thank's for the offer. As a new kind of workaround we introduced a extra route and we rewrite the URL there. So that way we did not have to change this library code, but it is another route and redirect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants