Skip to content
This repository has been archived by the owner on Feb 1, 2021. It is now read-only.

Set PromptBehavior to Auto if extraQueryParameters contains 'prompt=' #205

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/android/CordovaAdalPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
public class CordovaAdalPlugin extends CordovaPlugin {

private static final PromptBehavior SHOW_PROMPT_ALWAYS = PromptBehavior.Always;
private static final PromptBehavior SHOW_PROMPT_AUTO = PromptBehavior.Auto;


private static final int GET_ACCOUNTS_PERMISSION_REQ_CODE = 0;
private static final String PERMISSION_DENIED_ERROR = "Permissions denied";
Expand Down Expand Up @@ -207,7 +209,7 @@ private void acquireTokenAsync(String authority, boolean validateAuthority, Stri
clientId,
redirectUrl,
userId,
SHOW_PROMPT_ALWAYS,
(extraQueryParams != null && extraQueryParams.contains("prompt=")) ? SHOW_PROMPT_AUTO : SHOW_PROMPT_ALWAYS,
extraQueryParams,
new DefaultAuthenticationCallback(callbackContext));
}
Expand Down
2 changes: 1 addition & 1 deletion src/ios/CordovaAdalPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ - (void)acquireTokenAsync:(CDVInvokedUrlCommand *)command
acquireTokenWithResource:resourceId
clientId:clientId
redirectUri:redirectUri
promptBehavior:AD_PROMPT_ALWAYS
promptBehavior: (extraQueryParameters && [extraQueryParameters containsString: @"prompt="]) ? AD_PROMPT_AUTO : AD_PROMPT_ALWAYS
userId:userId
extraQueryParameters:extraQueryParameters
completionBlock:^(ADAuthenticationResult *result) {
Expand Down
5 changes: 3 additions & 2 deletions src/windows/ADALProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ var ADALProxy = {
var userId = args[5];
var extraQueryParameters = args[6];
var userIdentifier;
var defaultPromptBehavior = extraQueryParameters != undefined && extraQueryParameters.indexOf('prompt=') > -1 ? Microsoft.IdentityModel.Clients.ActiveDirectory.PromptBehavior.auto : Microsoft.IdentityModel.Clients.ActiveDirectory.PromptBehavior.always;

ADALProxy.getOrCreateCtx(authority, validateAuthority).then(function (context) {
userIdentifier = getUserIdentifier(context, userId);
Expand Down Expand Up @@ -179,13 +180,13 @@ var ADALProxy = {
// Try to SSO first
context.acquireTokenAsync(resourceUrl, clientId, Windows.Security.Authentication.Web.WebAuthenticationBroker.getCurrentApplicationCallbackUri(), Microsoft.IdentityModel.Clients.ActiveDirectory.PromptBehavior.never, userIdentifier, extraQueryParameters).then(function (res) {
handleAuthResult(win, function() {
context.acquireTokenAsync(resourceUrl, clientId, Windows.Security.Authentication.Web.WebAuthenticationBroker.getCurrentApplicationCallbackUri(), Microsoft.IdentityModel.Clients.ActiveDirectory.PromptBehavior.always, userIdentifier, extraQueryParameters).then(function (res) {
context.acquireTokenAsync(resourceUrl, clientId, Windows.Security.Authentication.Web.WebAuthenticationBroker.getCurrentApplicationCallbackUri(), defaultPromptBehavior, userIdentifier, extraQueryParameters).then(function (res) {
handleAuthResult(win, fail, res);
}, fail);
}, res);
}, fail);
} else {
context.acquireTokenAsync(resourceUrl, clientId, redirectUrl, Microsoft.IdentityModel.Clients.ActiveDirectory.PromptBehavior.always, userIdentifier, extraQueryParameters).then(function (res) {
context.acquireTokenAsync(resourceUrl, clientId, redirectUrl, defaultPromptBehavior, userIdentifier, extraQueryParameters).then(function (res) {
handleAuthResult(win, fail, res);
}, fail);
}
Expand Down