Skip to content

Mix auth0/angular-jwt & witoldsz/angular-http-auth to get automatic auth when response code is 401

Notifications You must be signed in to change notification settings

azzra/angular-jwt-auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

angular-jwt-auth

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


Documentation

Installation

bower install --save azzra/angular-jwt-auth

Build

gulp build

Set the login_check URL

angular.module('app', ['...', 'angular-jwt-auth', 'http-auth-interceptor'])....
// app.js
.config(function(angularJwtAuthToolsProvider) {
  angularJwtAuthToolsProvider.urlLoginCheck = '/login_check';
})

Custom methods

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);
  }];

});

About

Mix auth0/angular-jwt & witoldsz/angular-http-auth to get automatic auth when response code is 401

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •