Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- interceptors.module.js
- 'use strict';
- angular.module('core.interceptors',['authservice']);
- ======================================================================
- login-required.service.js
- 'use strict';
- angular.module('core.interceptors').factory('LoginRequiredInterceptor',LoginRequiredInterceptor).config(function($httpProvider) {
- $httpProvider.interceptors.push('LoginRequiredInterceptor');
- });
- function LoginRequiredInterceptor ($location,$q,autenticacao) {
- return {
- request: function(config) {
- config.headers = config.headers || {};
- // if (autenticacao.getToken()) {
- // config.headers['Authorization'] = {"Authorization": "JWT " + autenticacao.getToken()};
- // }
- return config;
- },
- responseError: function(response) {
- if (response.status === 401 || response.status === 403) {
- $location.path('/');
- }
- return $q.reject(response);
- }
- }
- }
- Erro
- 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