Advertisement
Marcus_Vinicius

Untitled

Jun 13th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. interceptors.module.js
  2. 'use strict';
  3.  
  4. angular.module('core.interceptors',['authservice']);
  5. ======================================================================
  6. login-required.service.js
  7.  
  8. 'use strict';
  9.  
  10. angular.module('core.interceptors').factory('LoginRequiredInterceptor',LoginRequiredInterceptor).config(function($httpProvider) {
  11.     $httpProvider.interceptors.push('LoginRequiredInterceptor');
  12. });
  13.  
  14. function LoginRequiredInterceptor ($location,$q,autenticacao) {
  15.   return {
  16.     request: function(config) {
  17.       config.headers = config.headers || {};
  18.       // if (autenticacao.getToken()) {
  19.       //    config.headers['Authorization'] = {"Authorization": "JWT " + autenticacao.getToken()};
  20.       // }
  21.       return config;
  22.     },
  23.  
  24.     responseError: function(response) {
  25.       if (response.status === 401 || response.status === 403) {
  26.         $location.path('/');
  27.       }
  28.  
  29.       return $q.reject(response);
  30.     }
  31.   }
  32. }
  33.  
  34. Erro
  35. Error: [$injector:cdep] http://errors.angularjs.org/1.5.8/$injector/cdep?p0=%24http%20%3C-%20autenticacao%20%3C-%20LoginRequiredInterceptor%20%3C-%20%24http%20%3C-%20%24templateRequest%20%3C-%20%24compile%20%3C-%20ngNotif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement