Skip to content
Draft
6 changes: 3 additions & 3 deletions src/app/core/services/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { inject, Injectable, PLATFORM_ID } from '@angular/core';
import { SignUpModel } from '@core/models/sign-up.model';
import { ENVIRONMENT } from '@core/provider/environment.provider';
import { ClearCurrentUser } from '@osf/core/store/user';
import { urlParam } from '@osf/shared/helpers/url-param.helper';
import { doubleEncodedUrlParam, urlParam } from '@osf/shared/helpers/url-param.helper';
import { JsonApiService } from '@osf/shared/services/json-api.service';
import { LoaderService } from '@osf/shared/services/loader.service';

Expand Down Expand Up @@ -41,7 +41,7 @@ export class AuthService {
}

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

Expand Down Expand Up @@ -79,7 +79,7 @@ export class AuthService {

if (isPlatformBrowser(this.platformId)) {
this.cookieService.deleteAll();
window.location.href = `${this.webUrl}/logout/?next=${encodeURIComponent('/')}`;
window.location.href = `${this.webUrl}/logout/?next=${encodeURIComponent(window.location.origin)}`;
}
}

Expand Down
12 changes: 12 additions & 0 deletions src/app/shared/helpers/url-param.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,15 @@ export const urlParam = (params: Record<string, string>) => {
.map((entry) => entry.map((comp) => encodeURIComponent(comp)).join('='))
.join('&');
};

export const doubleEncodedUrlParam = (params: { service: string; next?: string }): string => {
const { service, next } = params;

if (!next) {
return `service=${encodeURIComponent(service)}`;
}

const encodedNext = encodeURIComponent(next);
const valueAfterService = `${service}?next=${encodedNext}`;
return `service=${encodeURIComponent(valueAfterService)}`;
};
1 change: 1 addition & 0 deletions src/app/shared/mappers/institutions/institutions.mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class InstitutionsMapper {
logoPath: data.attributes.logo_path,
userMetricsUrl: data.relationships?.user_metrics?.links?.related?.href,
linkToExternalReportsArchive: data.attributes.link_to_external_reports_archive,
sso_availability: data.attributes.sso_availability,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ interface InstitutionAttributesJsonApi {
institutional_request_access_enabled: boolean;
logo_path: string;
link_to_external_reports_archive: string;
sso_availability: string;
}

interface InstitutionLinksJsonApi {
Expand Down
1 change: 1 addition & 0 deletions src/app/shared/models/institutions/institutions.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface Institution {
logoPath: string;
userMetricsUrl?: string;
linkToExternalReportsArchive?: string;
sso_availability: string;
}

export interface InstitutionAssets {
Expand Down
Loading