我正在为我的网站使用 Angular。最初,一旦页面启动,就没有任何问题,并且可以完美地进行身份验证。但是,刷新页面时,它不能再拉当前登录用户了。看起来它不调用Windows身份验证。我正在添加我的代码。任何帮助表示赞赏。
intercept(req: HttpRequest<any>, next: HttpHandler):
Observable<HttpEvent<any>> {
console.log('AppInterceptorService1111');
req = req.clone({
withCredentials: true
});
return next.handle(req)
.pipe(catchError(this.handleError));
}
本地存储已经实现。
this.authenticateCurrentNTLogin().subscribe((data: any) => {
this.currentUserInfoService.tokenInfo = data.Response;
localStorage.setItem('userToken', this.currentUserInfoService.tokenInfo.access_token);
localStorage.setItem('userRoles', this.currentUserInfoService.tokenInfo.role);
this.currentUserInfoService.currentUserTokenExpiration = new Date();
this.currentUserInfoService.currentUserTokenExpiration.setSeconds(new Date().getSeconds() + parseInt(this.currentUserInfoService.tokenInfo.expires_in));
localStorage.setItem('myTokenExpiration', this.currentUserInfoService.currentUserTokenExpiration.toLocaleDateString() +
' ' + this.currentUserInfoService.currentUserTokenExpiration.toLocaleTimeString());
},