mirror of
https://gitlab.silvrtree.co.uk/martind2000/aodb.git
synced 2025-01-28 22:46:17 +00:00
20 lines
622 B
TypeScript
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);
|
|
}
|
|
}
|