简体   繁体   English

身份验证期间刷新AngularJS SPA应用程序Azure AD

[英]AngularJS SPA Application Azure AD refresh during Authentication

We are trying to build an Angular SPA application that utilizes adal.js to authenticate with Azure AD. 我们正在尝试构建一个利用adal.js与Azure AD进行身份验证的Angular SPA应用程序。 However unlike the sample application which contains a static route the does not require authentication we would like to determine if a user is authenticated and route the user accordingly based on 'userInfo.isAuthenticated', however when taking this approach by using an ng-if on the index page we are redirected to the login correctly, but after entering you login credentials we have what appears to be a loop that occurs one to three times while the application is in the process of logging in. does anyone have a solution using ADAL.js and ADAL-angular.js to intercept the 'IsAuthenticating' property at the scope level to avoid this issue? 但是,与包含静态路由的示例应用程序不同,该应用程序不需要身份验证,我们希望确定用户是否已通过身份验证,并基于“ userInfo.isAuthenticated”对用户进行相应的路由,但是在使用ng-if on时采用这种方法索引页,我们可以正确地重定向到登录名,但是在输入登录凭据后,我们看到的循环似乎是在应用程序登录过程中发生了1至3次。有人使用ADAL解决方案吗? js和ADAL-angular.js在范围级别拦截'IsAuthenticating'属性,以避免此问题?

Thank you, 谢谢,

Can you provide some example code? 您能提供一些示例代码吗? It is not clear to me about your scenario. 我不清楚您的情况。 Are you just trying to show/hide links on the page? 您是否只是想在页面上显示/隐藏链接? Sample app uses ng-show using userInfo.isAuthenticated. 示例应用使用userInfo.isAuthenticated进行ng-show。 Are you using ng-if on this page and not working? 您是否在此页面上使用ng-if并且无法正常工作? I expect them to work similar for ng-show and ng-if since it checks boolean value. 我希望它们对ng-show和ng-if起作用,因为它会检查布尔值。

<div class="navbar-collapse collapse">
                <ul class="nav navbar-nav">
                    <li ng-class="{ active: isActive('/Home') }"><a href="#/Home">Home</a></li>
                    <li ng-class="{ active: isActive('/TodoList') }"><a href="#/TodoList">Todo List</a></li>
                    <li ng-class="{ active: isActive('/UserData') }"><a href="#/UserData" ng-show="userInfo.isAuthenticated">User</a></li>
                </ul>
                <ul class="nav navbar-nav navbar-right">
                    <li><a class="btn btn-link" ng-show="userInfo.isAuthenticated" ng-click="logout()">Logout</a></li>
                    <li><a class="btn btn-link" ng-hide=" userInfo.isAuthenticated" ng-click="login()">Login</a></li>
                </ul>
            </div>

Sample: https://github.com/AzureADSamples/SinglePageApp-AngularJS-DotNet/blob/master/TodoSPA/index.html 范例: https//github.com/AzureADSamples/SinglePageApp-AngularJS-DotNet/blob/master/TodoSPA/index.html

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

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