mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-23 02:35:17 +01:00
Fix xsrf error status bug when after beego update
Signed-off-by: Yogi_Wang <yawang@vmware.com>
This commit is contained in:
parent
5f2544941e
commit
2bbb37e6b5
@ -24,7 +24,7 @@ describe('InterceptHttpService', () => {
|
||||
return of(new HttpResponse({status: 200}));
|
||||
} else {
|
||||
return throwError(new HttpResponse( {
|
||||
status: 403
|
||||
status: 422
|
||||
}));
|
||||
}
|
||||
}
|
||||
@ -48,7 +48,7 @@ describe('InterceptHttpService', () => {
|
||||
(service: InterceptHttpService) => {
|
||||
mockCookieService.set("fdsa|ds");
|
||||
service.intercept(mockRequest, mockHandle).subscribe(res => {
|
||||
if (res.status === 403) {
|
||||
if (res.status === 422) {
|
||||
expect(btoa(mockRequest.headers.get("X-Xsrftoken"))).toEqual(cookie.split("|")[0]);
|
||||
} else {
|
||||
expect(res.status).toEqual(200);
|
||||
|
@ -14,7 +14,7 @@ export class InterceptHttpService implements HttpInterceptor {
|
||||
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<any> {
|
||||
|
||||
return next.handle(request).pipe(catchError(error => {
|
||||
if (error.status === 403) {
|
||||
if (error.status === 422) {
|
||||
let Xsrftoken = this.cookie.get("_xsrf") ? atob(this.cookie.get("_xsrf").split("|")[0]) : null;
|
||||
if (Xsrftoken && !request.headers.has('X-Xsrftoken')) {
|
||||
request = request.clone({ headers: request.headers.set('X-Xsrftoken', Xsrftoken) });
|
||||
|
Loading…
Reference in New Issue
Block a user