Skip to content

Commit

Permalink
Merge pull request #27 from jmangelo/fix/incorrect-hash-handling
Browse files Browse the repository at this point in the history
Replace direct query of window.location.hash with the location service
  • Loading branch information
chenkie committed Mar 29, 2017
2 parents 05508f7 + 5bec6e1 commit 4dcbfa7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
8 changes: 3 additions & 5 deletions angular-lock.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@

this.$get = [
'$rootScope',
function($rootScope) {
'$location',
function($rootScope, $location) {
var Lock = new Auth0Lock(this.clientID, this.domain, this.options);
var credentials = { clientID: this.clientID, domain: this.domain };
var shouldVerifyIdToken = true;
Expand Down Expand Up @@ -83,10 +84,7 @@
if (/id_token=/.test(location) || /error=/.test(location)) {
var webAuth = new auth0.WebAuth(credentials);

// Hash simulation for html5Mode(true).
var hash = window.location.hash
? window.location.hash
: '#' + location.replace(/http.?:\/\/[^/]+/, '').slice(1);
var hash = $location.hash();

webAuth.parseHash(
{ hash: hash, _idTokenVerification: shouldVerifyIdToken },
Expand Down
8 changes: 3 additions & 5 deletions dist/angular-lock.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@

this.$get = [
'$rootScope',
function($rootScope) {
'$location',
function($rootScope, $location) {
var Lock = new Auth0Lock(this.clientID, this.domain, this.options);
var credentials = { clientID: this.clientID, domain: this.domain };
var shouldVerifyIdToken = true;
Expand Down Expand Up @@ -83,10 +84,7 @@
if (/id_token=/.test(location) || /error=/.test(location)) {
var webAuth = new auth0.WebAuth(credentials);

// Hash simulation for html5Mode(true).
var hash = window.location.hash
? window.location.hash
: '#' + location.replace(/http.?:\/\/[^/]+/, '').slice(1);
var hash = $location.hash();

webAuth.parseHash(
{ hash: hash, _idTokenVerification: shouldVerifyIdToken },
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-lock.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4dcbfa7

Please sign in to comment.