Skip to content

Commit f3707fa

Browse files
authored
Merge pull request #886 from ihorsokhanexoft/fix/ENG-10262-2
fix(ENG-10262): fixed login url encoding
2 parents ebe88f6 + ef75a2e commit f3707fa

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/app/core/services/auth.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { inject, Injectable, PLATFORM_ID } from '@angular/core';
88
import { SignUpModel } from '@core/models/sign-up.model';
99
import { ENVIRONMENT } from '@core/provider/environment.provider';
1010
import { ClearCurrentUser } from '@osf/core/store/user';
11-
import { urlParam } from '@osf/shared/helpers/url-param.helper';
11+
import { doubleEncodedUrlParam, urlParam } from '@osf/shared/helpers/url-param.helper';
1212
import { JsonApiService } from '@osf/shared/services/json-api.service';
1313
import { LoaderService } from '@osf/shared/services/loader.service';
1414

@@ -41,7 +41,7 @@ export class AuthService {
4141
}
4242

4343
this.loaderService.show();
44-
const loginUrl = `${this.casUrl}/login?${urlParam({ service: `${this.webUrl}/login`, next: window.location.href })}`;
44+
const loginUrl = `${this.casUrl}/login?${doubleEncodedUrlParam({ service: `${this.webUrl}/login`, next: window.location.href })}`;
4545
window.location.href = loginUrl;
4646
}
4747

src/app/shared/helpers/url-param.helper.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,15 @@ export const urlParam = (params: Record<string, string>) => {
33
.map((entry) => entry.map((comp) => encodeURIComponent(comp)).join('='))
44
.join('&');
55
};
6+
7+
export const doubleEncodedUrlParam = (params: { service: string; next?: string }): string => {
8+
const { service, next } = params;
9+
10+
if (!next) {
11+
return `service=${encodeURIComponent(service)}`;
12+
}
13+
14+
const encodedNext = encodeURIComponent(next);
15+
const valueAfterService = `${service}?next=${encodedNext}`;
16+
return `service=${encodeURIComponent(valueAfterService)}`;
17+
};

0 commit comments

Comments
 (0)