JamesRandall / AngularJS-OAuth2

Package for allowing an AngularJS application to authenticate with an OAuth 2 / Open ID Connect identity provider using the implicit flow.
MIT License
46 stars 42 forks source link

Not working when html5Mode is enabled for routing #1

Closed bvuden closed 9 years ago

bvuden commented 9 years ago

Hi,

When html5Mode for routing is enabled in AngularJS the url param that is received after login starts with a hash (f.e. http://localhost:1881/#access_token=). Because of this the acces_token is not retrieved from the url parameter. I implemented a quick fix in service.set:

if (hashValues.indexOf('#/') == 0) {
hashValues = hashValues.substring(2);

to

if (hashValues.indexOf('#') == 0) {
hashValues = hashValues.substring(1);

This fixed the issue for me. Maybe you can add an option to the directive for html5Mode?

Cheers, Bart

JamesRandall commented 9 years ago

Hi Bart,

Good idea - I'll do that. Thanks.

James

bvuden commented 9 years ago

Thanks! Nice plugin by the way, i'm using it in a small project right now.

Bart

JamesRandall commented 9 years ago

Hi Bart,

I've fixed the HTML5 routing issue. The directive will detect the routing mode and behave accordingly.

James