I have deployed my Angular Web App over the IIS and we have a page where router guard is enabled and that's the first page, that'll come after the authentication popup.
Within the Auth Guard we have called an API which in turn return current windows login username and we have an interceptor for the same which in between check weather the endpoint returns 401 Unauthorized error and after catching the same I'm reloading the page using window.location.reload().
So on click of Cancel of Windows Authentication popup in chrome after page reload able to see the windows authentication popup. Bu开发者_运维知识库t the same popup is not visible under Edge and Firefox again on click of cancel.
Because I have given the fix as to reload the page on the 401: Unauthorized Error with window.location.reload() under the interceptor.
error-handler.interceptor.ts
import { Injectable } from '@angular/core';
import {
HttpRequest,
HttpHandler,
HttpEvent,
HttpInterceptor,
HttpResponse
} from '@angular/common/http';
import { Observable } from 'rxjs';
import { tap } from 'rxjs/operators';
import { GlobalMessages } from '../data/messages';
import { MessageDialogType } from '../types/message-type';
import { MessageService } from './message-service';
@Injectable()
export class ErrorHandlerInterceptor implements HttpInterceptor {
constructor( private msg: MessageService) {}
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
return next.handle(request).pipe(tap(
event => event instanceof HttpResponse ? 'succeeded' : '',
err => {
if(err.status === 401){
window.location.reload();
}else{
// Some error message popup
}
}
))
}
}
app.routing.ts
app.module.ts
Windows Authentication Popup
Issue: On cancel after page reload popup is not coming again in Firefox and Microsoft Edge. But the same is working in chrome
精彩评论