Skip to content

Commit ef75a2e

Browse files
fix(ENG-10262): unified encoding of login
1 parent 54cb9ec commit ef75a2e

2 files changed

Lines changed: 3 additions & 10 deletions

File tree

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

Lines changed: 2 additions & 9 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 { localUrlParam, 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,14 +41,7 @@ export class AuthService {
4141
}
4242

4343
this.loaderService.show();
44-
let loginUrl = null;
45-
if (this.environment.webUrl.includes('localhost')) {
46-
// CAS should handle auth instead of angular, so we need to pass the next param
47-
// in the service param to ensure the user is redirected back to the correct page after login
48-
loginUrl = `${this.casUrl}/login?${localUrlParam({ service: `${this.webUrl.replace('4200', '5000')}/login`, next: window.location.href })}`;
49-
} else {
50-
loginUrl = `${this.casUrl}/login?${urlParam({ service: `${this.webUrl}/login`, next: window.location.href })}`;
51-
}
44+
const loginUrl = `${this.casUrl}/login?${doubleEncodedUrlParam({ service: `${this.webUrl}/login`, next: window.location.href })}`;
5245
window.location.href = loginUrl;
5346
}
5447

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export const urlParam = (params: Record<string, string>) => {
44
.join('&');
55
};
66

7-
export const localUrlParam = (params: { service: string; next?: string }): string => {
7+
export const doubleEncodedUrlParam = (params: { service: string; next?: string }): string => {
88
const { service, next } = params;
99

1010
if (!next) {

0 commit comments

Comments
 (0)