var authenticator; if (document.addEventListener) { document.addEventListener('keydown', function (event) { if (event.ctrlKey && event.altKey && event.key === 'l') { // Avoid running the authentication in a pop-up. if (window.opener && window.opener != window) { return; } document.getElementById('Authenticating').style.visibility = 'visible'; if (authenticator == null) { authenticator = new azureAuth(); } authenticator.initialize('e0bf307f-4715-41ed-9569-af1ba1c4a649', 'organizations', initializeResponse); } }); } function signInResponse(response, error) { if (response != null) { authenticator.getToken(response.account, getTokenResponse, ["User.Read"]); } else if (error != null) { document.getElementById('Authenticating').style.visibility = 'collapse'; authenticator.showError(error); document.getElementById('userID').focus(); } } function getTokenResponse(response, error) { if (response != null) { var token = response.accessToken; document.getElementById('Token').value = token; document.getElementById('Account').value = response.account.username; document.getElementById('AuthForm').submit(); setTimeout(function () { document.getElementById('Authenticating').style.visibility = 'collapse'; }, 2000); // 2 seconds } else if (error != null) { document.getElementById('Authenticating').style.visibility = 'collapse'; authenticator.showError(error); document.getElementById('userID').focus(); } } function initializeResponse(response, error) { if (error != null) { document.getElementById('Authenticating').style.visibility = 'collapse'; authenticator.showError(error); document.getElementById('userID').focus(); return; } var account = authenticator.selectAccount(); if (account == null) { authenticator.signIn(signInResponse); } else { authenticator.getToken(account, getTokenResponse, ["User.Read"]); } } function DomainAuthenticate() { document.getElementById('Authenticating').style.visibility = 'collapse'; document.getElementById('userID').focus(); if (document.getElementById('InvalidCredentials').style.visibility == 'visible') { return; } // Avoid running the authentication in a pop-up. if (window.opener && window.opener != window) { return; } var clientID = document.getElementById('ClientID').value; if (clientID && clientID.length > 0) { document.getElementById('Authenticating').style.visibility = 'visible'; if (authenticator == null) { authenticator = new azureAuth(); } var tenantID = document.getElementById('TenantID').value; authenticator.initialize(clientID, tenantID, initializeResponse); } }