Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: app migration #3069

Merged
merged 1 commit into from
Mar 27, 2024
Merged
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
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
Loading