aodb/app/authentication/services/authentication.interceptor.ts
Martin Donnelly afe73b5baa upload
2016-12-22 00:00:06 +00:00

20 lines
622 B
TypeScript

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<ng.ui.IStateService>('$state');
if (rejection.status === 401) {
state.go('login', { redirected: true });
return this.$q.reject(rejection);
}
return this.$q.reject(rejection);
}
}