Skip to content

Commit 9b65d1b

Browse files
Add function to set Msal Cookie in an override function
1 parent 86517f8 commit 9b65d1b

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/js/api.library.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,6 +1190,13 @@ api.sso.logout = function (callbackFunctionName_onSuccess, callbackFunctionName_
11901190
});
11911191
};
11921192

1193+
/**
1194+
* function to optionally override in local application
1195+
* @param {*} accessToken
1196+
* @param {*} expiresOn
1197+
* @param {*} domain
1198+
*/
1199+
api.sso.setMsalCookieOverride = function (accessToken, expiresOn, domain) { };
11931200

11941201
/**
11951202
* check if the user has an entra account and retrieve token if present
@@ -1228,12 +1235,17 @@ api.sso.acquireAccessTokenSilently = async function () {
12281235
}).then((response) => {
12291236
// User is authenticated, return access token
12301237
api.sso.tokenPromise = null; // clear cache i.e. mark the promise as complete
1238+
//put access token into domain cookie
1239+
api.sso.setMsalCookieOverride(response.accessToken, response.expiresOn);
1240+
12311241
return response.accessToken;
12321242
}).catch(async (error) => {
12331243
if (error instanceof msal.InteractionRequiredAuthError) {
12341244
const response = await api.sso.authenticateUserPopupAsync();
12351245
api.sso.tokenPromise = null;
12361246
if (response.accessToken) {
1247+
//put access token into domain cookie
1248+
api.sso.setMsalCookieOverride(response.accessToken, response.expiresOn);
12371249
return response.accessToken;
12381250
} else {
12391251
return null

0 commit comments

Comments
 (0)