Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* @ngInject */
- $httpProvider.interceptors.push(function ($rootScope, $q, localStorageService) {
- return {
- request: function (config) {
- config.headers = config.headers || {};
- var authToken = getAuthToken();
- if (authToken) {
- config.headers.Authorization = 'Bearer ' + authToken;
- }
- return config;
- },
- responseError: function (rejection) {
- if (!rejection.config.ignoreAuthModule) {
- switch (rejection.status) {
- case 401:
- $rootScope.$broadcast('event:auth-login-required', rejection);
- break;
- case 403:
- $rootScope.$broadcast('event:auth-forbidden', rejection);
- break;
- }
- }
- return $q.reject(rejection);
- }
- };
- });
Advertisement
Add Comment
Please, Sign In to add comment