简体   繁体   English

Windows身份验证+角度。 防止登录提示

[英]Windows authentication + angular. Prevent login prompt

I'm tryng to authenticate my angular app with Windows auth. 我正在尝试使用Windows身份验证来验证我的角度应用程序。 I make a call to an authorized api and wait for result to check if user is a windows user. 我呼叫授权的 api,然后等待结果检查该用户是否为Windows用户。

If user is authorized everything is ok, api return 200 status code. 如果授权用户一切正常,则api返回200状态代码。

If user is unauthorized a browser default login popup be shown. 如果用户未经授权,则会显示浏览器默认登录弹出窗口。 I want to intercept 401 response and show a custom error dialog, not the browser popup 我想拦截401响应并显示自定义错误对话框,而不是浏览器弹出窗口

There is a way to prevent login popup to be shown? 有一种方法可以防止显示登录弹出窗口?

Thanks. 谢谢。

Here an example of my request: 这是我的要求的一个例子:

var ret = this.http.get(this.baseUrl + this._hello, {headers: {'X-Requested-With':'XMLHttpRequest'}, withCredentials:true})
        .map(this.extractDataa)
        .catch(this.handleError);

If you have an authenticated (any variable name will work) variable in the .ts file of the component that contains the log-in pop-up, you can use that variable in the .html of the component. 如果在包含登录弹出窗口的组件的.ts文件中具有经过authenticated变量(任何变量名都可以使用),则可以在组件的.html中使用该变量。

<ng-container *ngIf="!authenticated">
  <app-login>/* log-in component */<app-login>
<ng-container>

This will only render the content in the ng-container if authenticated is false 如果authenticatedfalse这只会在ng-container呈现内容

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM