Adds frontend redirect interceptor for logged in users with non-verified email.

This commit is contained in:
gkolokythas 2019-07-12 17:15:37 +03:00
parent f8310b2362
commit f50b27128c
3 changed files with 30 additions and 0 deletions

View File

@ -7,6 +7,7 @@ import { ProgressIndicationInterceptor } from './interceptors/progress-indicatio
import { RequestTimingInterceptor } from './interceptors/request-timing.interceptor';
import { ResponsePayloadInterceptor } from './interceptors/response-payload.interceptor';
import { UnauthorizedResponseInterceptor } from './interceptors/unauthorized-response.interceptor';
import { StatusCodeInterceptor } from './interceptors/status-code.interceptor';
@NgModule({
imports: [
@ -48,6 +49,11 @@ import { UnauthorizedResponseInterceptor } from './interceptors/unauthorized-res
provide: HTTP_INTERCEPTORS,
useClass: ResponsePayloadInterceptor,
multi: true,
},
{
provide: HTTP_INTERCEPTORS,
useClass: StatusCodeInterceptor,
multi: true,
}
]
})

View File

@ -6,4 +6,5 @@ export enum InterceptorType {
RequestTiming = 4,
UnauthorizedResponse = 5,
ResponsePayload = 5,
StatusCode = 6
}

View File

@ -0,0 +1,23 @@
import { Injectable } from "@angular/core";
import { BaseInterceptor } from "./base.interceptor";
import { InterceptorType } from "./interceptor-type";
import { HttpHandler, HttpRequest, HttpEvent } from "@angular/common/http";
import { Observable } from "rxjs";
import { Router } from "@angular/router";
@Injectable()
export class StatusCodeInterceptor extends BaseInterceptor {
type: InterceptorType;
interceptRequest(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent <any>> {
return next.handle(req).do(event => { }, err => {
if (err.status === 480) {
this.router.navigate(['confirmation']);
}
});
}
constructor(
private router: Router,
) { super(); }
}