import {controller, directive, factory} from '../../infrastructure/Dectorators/Components'; import {Mod} from '../auth.mod'; @factory(Mod, 'authenticationInterceptor', ['$q', '$injector']) export class AuthenticationInterceptor { constructor(private $q: ng.IQService, private $injector: ng.auto.IInjectorService) { }; responseError = (rejection) => { let state: ng.ui.IStateService = this.$injector.get('$state'); if (rejection.status === 401) { state.go('login', { redirected: true }); return this.$q.reject(rejection); } return this.$q.reject(rejection); } }