Mix auth0/angular-jwt & witoldsz/angular-http-auth to get automatic auth when response code is 401.
DEPRECATED as it's only compatible with AngularJS
NO TESTS
bower install --save azzra/angular-jwt-auth
gulp build
angular.module('app', ['...', 'angular-jwt-auth', 'http-auth-interceptor'])....
// app.js
.config(function(angularJwtAuthToolsProvider) {
angularJwtAuthToolsProvider.urlLoginCheck = '/login_check';
})
You can override the angularJwtAuthTools
methods.
angular.module('angular-jwt-auth', ['angular-jwt', 'angular-jwt-auth.tools', 'LocalStorageModule'])
.config(function($httpProvider, jwtInterceptorProvider, angularJwtAuthToolsProvider) {
// Please note we're annotating the function so that the $injector works when the file is minified
angularJwtAuthToolsProvider.saveToken = ['localStorageService', function(localStorageService) {
// "this" is set by $injector, https://docs.angularjs.org/api/auto/service/$injector
localStorageService.set('auth.jwt_token', this);
}];
});