Skip to content
This repository has been archived by the owner. It is now read-only.

Commit 57112f0

Browse files
committed
add login type
1 parent c933c29 commit 57112f0

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

JavaScriptSPA/index.html

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
clientID: "245e9392-c666-4d51-8f8a-bfd9e55b2456",
2323
authority: "https://login.microsoftonline.com/common",
2424
graphScopes: ["user.read", "Mail.Send"],
25-
graphEndpoint: "https://graph.microsoft.com/v1.0/me"
25+
graphEndpoint: "https://graph.microsoft.com/v1.0/me",
26+
loginType: 'POPUP'
2627
};
2728

2829
var config = {
@@ -140,23 +141,15 @@
140141
errorMessage.indexOf("interaction_required") !== -1 ||
141142
errorMessage.indexOf("login_required") !== -1;
142143
}
143-
// Browser check variables
144-
var ua = window.navigator.userAgent;
145-
var msie = ua.indexOf('MSIE ');
146-
var msie11 = ua.indexOf('Trident/');
147-
var msedge = ua.indexOf('Edge/');
148-
var isIE = msie > 0 || msie11 > 0;
149-
var isEdge = msedge > 0;
150-
151-
//If you support IE, our recommendation is that you sign-in using Redirect APIs
152-
//If you as a developer are testing using Edge InPrivate mode, please add "isEdge" to the if check
153-
if (!isIE) {
144+
145+
// runs on page load, change config to try different login types to see what is best for your application
146+
if (applicationConfig.loginType === 'POPUP') {
154147
if (myMSALObj.getAccount()) {// avoid duplicate code execution on page load in case of iframe and popup window.
155148
showWelcomeMessage();
156149
acquireTokenPopupAndCallMSGraph();
157150
}
158151
}
159-
else {
152+
else if (applicationConfig.loginType === 'REDIRECT') {
160153
document.getElementById("SignIn").onclick = function () {
161154
let redirectTokenRequest = {
162155
scopes: applicationConfig.graphScopes
@@ -168,6 +161,8 @@
168161
showWelcomeMessage();
169162
acquireTokenRedirectAndCallMSGraph();
170163
}
164+
} else {
165+
console.error('Please choose a valid login type');
171166
}
172167
</script>
173168
</body>

0 commit comments

Comments
 (0)