Skip to content

Commit

Permalink
Make redirector handle annotations. Fix #87.
Browse files Browse the repository at this point in the history
  • Loading branch information
chenkie committed Aug 19, 2016
1 parent 6ab0432 commit 5c1a0b3
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
11 changes: 9 additions & 2 deletions dist/angular-jwt.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,15 @@ angular.module('angular-jwt.authManager', [])

function redirectWhenUnauthenticated() {
$rootScope.$on('unauthenticated', function() {
config.unauthenticatedRedirector($location);
unauthenticate();
var redirector = config.unauthenticatedRedirector;
var redirectFn;
if(Array.isArray(redirector)) {
redirectFn = redirector[redirector.length - 1];
redirectFn($location);
unauthenticate();
} else {
redirector($location);
}
});
}

Expand Down
2 changes: 1 addition & 1 deletion dist/angular-jwt.min.js

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-jwt",
"version": "0.1.1",
"version": "0.1.2",
"description": "Library to help you work with JWTs on AngularJS",
"main": "index.js",
"license": "MIT",
Expand Down
11 changes: 9 additions & 2 deletions src/angularJwt/services/authManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,15 @@ angular.module('angular-jwt.authManager', [])

function redirectWhenUnauthenticated() {
$rootScope.$on('unauthenticated', function() {
config.unauthenticatedRedirector($location);
unauthenticate();
var redirector = config.unauthenticatedRedirector;
var redirectFn;
if(Array.isArray(redirector)) {
redirectFn = redirector[redirector.length - 1];
redirectFn($location);
unauthenticate();
} else {
redirector($location);
}
});
}

Expand Down

0 comments on commit 5c1a0b3

Please sign in to comment.