Skip to content

Commit f6263e4

Browse files
Ostap-ZherebetskyiihorsokhanexoftnsemetsVlad0n20cslzchen
authored
[ENG-10275] [ENG-10802] OSF4I In-progress SSO - FE Piece (#967)
* fixed login url encoding * unified encoding of login * Update logout url * Add sso_availability attribute to Institution model and mapper * simplify login url construction and remove helper * fix institution unit tests * update logout redirect url to ensure proper navigation --------- Co-authored-by: Ihor Sokhan <isokhan@exoft.net> Co-authored-by: nsemets <nsemets@exoft.net> Co-authored-by: Vlad0n20 <vlad.onischuk1234@gmail.com> Co-authored-by: Longze Chen <cslzchen@gmail.com>
1 parent 3945dd2 commit f6263e4

8 files changed

Lines changed: 20 additions & 3 deletions

File tree

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,14 @@ export class AuthService {
4141
}
4242

4343
this.loaderService.show();
44-
const loginUrl = `${this.casUrl}/login?${urlParam({ service: `${this.webUrl}/login`, next: window.location.href })}`;
45-
window.location.href = loginUrl;
44+
45+
const serviceUrl = new URL(`${this.webUrl}/login`);
46+
serviceUrl.searchParams.set('next', window.location.href);
47+
48+
const loginUrl = new URL(`${this.casUrl}/login`);
49+
loginUrl.searchParams.set('service', serviceUrl.toString());
50+
51+
window.location.href = loginUrl.toString();
4652
}
4753

4854
navigateToOrcidSignIn(): void {
@@ -79,7 +85,7 @@ export class AuthService {
7985

8086
if (isPlatformBrowser(this.platformId)) {
8187
this.cookieService.deleteAll();
82-
window.location.href = `${this.webUrl}/logout/?next=${encodeURIComponent(nextUrl || '/')}`;
88+
window.location.href = `${this.webUrl}/logout/?next=${encodeURIComponent(nextUrl || `${window.location.origin}/`)}`;
8389
}
8490
}
8591

src/app/features/profile/components/profile-information/profile-information.component.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ describe('ProfileInformationComponent', () => {
3737
},
3838
institutionalRequestAccessEnabled: true,
3939
logoPath: 'logo.png',
40+
sso_availability: 'Public',
4041
},
4142
];
4243

src/app/features/project/overview/components/add-component-dialog/add-component-dialog.component.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ describe('AddComponentDialogComponent', () => {
6464
assets: { logo: '', logo_rounded: '', banner: '' },
6565
institutionalRequestAccessEnabled: false,
6666
logoPath: '',
67+
sso_availability: 'Public',
6768
},
6869
{
6970
id: 'inst-2',
@@ -76,6 +77,7 @@ describe('AddComponentDialogComponent', () => {
7677
assets: { logo: '', logo_rounded: '', banner: '' },
7778
institutionalRequestAccessEnabled: false,
7879
logoPath: '',
80+
sso_availability: 'Public',
7981
},
8082
];
8183

@@ -91,6 +93,7 @@ describe('AddComponentDialogComponent', () => {
9193
assets: { logo: '', logo_rounded: '', banner: '' },
9294
institutionalRequestAccessEnabled: false,
9395
logoPath: '',
96+
sso_availability: 'Public',
9497
},
9598
];
9699

src/app/shared/components/affiliated-institution-select/affiliated-institution-select.component.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ describe('AffiliatedInstitutionSelectComponent', () => {
6868
},
6969
institutionalRequestAccessEnabled: false,
7070
logoPath: '/logos/unavailable.png',
71+
sso_availability: 'Unavailable',
7172
};
7273

7374
fixture.componentRef.setInput('institutions', mockInstitutions);
@@ -134,6 +135,7 @@ describe('AffiliatedInstitutionSelectComponent', () => {
134135
},
135136
institutionalRequestAccessEnabled: false,
136137
logoPath: '/logos/unavailable.png',
138+
sso_availability: 'Unavailable',
137139
};
138140

139141
fixture.componentRef.setInput('institutions', mockInstitutions);
@@ -181,6 +183,7 @@ describe('AffiliatedInstitutionSelectComponent', () => {
181183
},
182184
institutionalRequestAccessEnabled: false,
183185
logoPath: '/logos/unavailable.png',
186+
sso_availability: 'Unavailable',
184187
};
185188

186189
fixture.componentRef.setInput('institutions', mockInstitutions);

src/app/shared/mappers/institutions/institutions.mapper.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export class InstitutionsMapper {
2525
logoPath: data.attributes.logo_path,
2626
userMetricsUrl: data.relationships?.user_metrics?.links?.related?.href,
2727
linkToExternalReportsArchive: data.attributes.link_to_external_reports_archive,
28+
sso_availability: data.attributes.sso_availability,
2829
};
2930
}
3031

src/app/shared/models/institutions/institution-json-api.model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ interface InstitutionAttributesJsonApi {
2323
institutional_request_access_enabled: boolean;
2424
logo_path: string;
2525
link_to_external_reports_archive: string;
26+
sso_availability: string;
2627
}
2728

2829
interface InstitutionLinksJsonApi {

src/app/shared/models/institutions/institutions.model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export interface Institution {
1616
logoPath: string;
1717
userMetricsUrl?: string;
1818
linkToExternalReportsArchive?: string;
19+
sso_availability: string;
1920
}
2021

2122
export interface InstitutionAssets {

src/testing/mocks/institution.mock.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ export const MOCK_INSTITUTION = {
1313
},
1414
institutionalRequestAccessEnabled: true,
1515
logoPath: 'https://mockinstitution.org/logo.png',
16+
sso_availability: 'Public',
1617
};

0 commit comments

Comments
 (0)