1

I have a very simple application with HTML, AngularJS and I want to use adal-js and adal-angular-js. The app is this:

var app = angular.module('myApp', ['ngRoute', 'AdalAngular']);
app.config([
    '$routeProvider', '$httpProvider', 'adalAuthenticationServiceProvider', 
    function ($routeProvider, $httpProvider, adalProvider) {

        $routeProvider
            .when('/', {
                templateUrl: "App/Views/home.html",
                controller:'myCtrl',
                requireADLogin:true,
            }).when("/autenticado", {
                templateUrl: "App/Views/autenticado.html",
                controller:'authCtrl',
            });

        adalProvider.init(
            {
                instance: 'https://login.microsoftonline.com/',
                tenant: 'supervisorxher34outlook.onmicrosoft.com',
                clientId: 'e5b17ad1-8f2d-4716-a9ad-748c48222e23',
                extraQueryParameter: 'nux=1',
                //cacheLocation: 'localStorage', // enable this for IE, as sessionStorage does not work for localhost.
            },
            $httpProvider
        );
    }
]);

The home HTML, is just a simple hello world.

When I enter the page, it redirects me to the login page, but as soon as I put my username and password it keeps refreshing endlessly, and never stops.

Any idea why is this happening?

Thanks!

Philippe Signoret
  • 13,299
  • 1
  • 40
  • 58
carlos
  • 815
  • 2
  • 14
  • 27
  • is this happening every time a user tries to login? or is it only after the site has been idle for some time? has it ever worked for you so far (because if it hasn't, then it may be initial configuration related).. Also make sure "oauth2AllowImplicitFlow" is set to true in your application manifest – Rohit Saigal Oct 20 '18 at 12:59
  • Phillippe, thanks for your answer, I solved the problem, and I am a little ashame, couse it was so easy. Somewhere hidden in the npm information of the library clearly states that "When HTML5 mode is configured, ensure the $locationProvider hashPrefix is set... Without the hashPrefix set, the AAD login will loop indefinitely".. so after a few changes in the code, it works! ... Thanks any way for the help! – carlos Oct 22 '18 at 01:08
  • That makes sense. We all miss small things in beginning so no worries there :) – Rohit Saigal Oct 22 '18 at 01:13

1 Answers1

0

A little bit ashamed, but the answer was so easy:

 $locationProvider.html5Mode({
        enabled:true,
        requireBase: false
    }).hashPrefix('!');

Just needed to add the $locationProvider.

harriyott
  • 10,505
  • 10
  • 64
  • 103
carlos
  • 815
  • 2
  • 14
  • 27