Skip to content

Commit

Permalink
Chore: app migration (#3069)
Browse files Browse the repository at this point in the history
  • Loading branch information
thewahome authored Mar 27, 2024
1 parent d88a4f8 commit 46aada7
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/modules/authentication/AuthenticationWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ export class AuthenticationWrapper implements IAuthenticationWrapper {
selectedVersion: '',
sampleHeaders: []
};
private extraQueryParameters: { [key: string]: string } = (() => {
const params: { [key: string]: string } = {
mkt: geLocale
};

const migrationParam = process.env.REACT_APP_MIGRATION_PARAMETER;
if (migrationParam) {
params.MigrationQueryParam = migrationParam;
}

return params;
})();

public static getInstance(): AuthenticationWrapper {
if (!AuthenticationWrapper.instance) {
Expand All @@ -50,15 +62,15 @@ export class AuthenticationWrapper implements IAuthenticationWrapper {
}

public async logIn(sessionId = '', sampleQuery?: IQuery): Promise<AuthenticationResult> {
if(sampleQuery){
if (sampleQuery) {
this.sampleQuery = sampleQuery;
this.performingStepUpAuth = true;
}
this.consentingToNewScopes = false;
// eslint-disable-next-line no-useless-catch
try {
const authResult = await this.getAuthResult([], sessionId);
if(this.performingStepUpAuth && authResult){
if (this.performingStepUpAuth && authResult) {
this.claimsAvailable = true;
}
return authResult;
Expand All @@ -73,7 +85,7 @@ export class AuthenticationWrapper implements IAuthenticationWrapper {
authority: this.getAuthority(),
prompt: 'select_account',
redirectUri: getCurrentUri(),
extraQueryParameters: { mkt: geLocale }
extraQueryParameters: this.extraQueryParameters
};
try {
const result = await msalApplication.loginPopup(popUpRequest);
Expand Down Expand Up @@ -180,7 +192,7 @@ export class AuthenticationWrapper implements IAuthenticationWrapper {

private getClaims(): string | undefined {
const account = this.getAccount();
if(account && (this.sampleQuery.sampleUrl !== '')){
if (account && (this.sampleQuery.sampleUrl !== '')) {
const claimsChallenge = new ClaimsChallenge(this.sampleQuery, account);
const storedClaims = claimsChallenge.getClaimsFromStorage();
return storedClaims ? window.atob(storedClaims) : undefined;
Expand All @@ -205,9 +217,10 @@ export class AuthenticationWrapper implements IAuthenticationWrapper {
authority: this.getAuthority(),
prompt: 'select_account',
redirectUri: getCurrentUri(),
extraQueryParameters: { mkt: geLocale },
extraQueryParameters: this.extraQueryParameters,
claims: this.getClaims()
};
console.log('popUpRequest', popUpRequest)

if (this.consentingToNewScopes || this.performingStepUpAuth) {
delete popUpRequest.prompt;
Expand Down

0 comments on commit 46aada7

Please sign in to comment.