Skip to content
Merged
Show file tree
Hide file tree
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
15 changes: 15 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@

We follow the CalVer (https://calver.org/) versioning scheme: YY.MINOR.MICRO.

26.10.1 (2026-05-15)
====================

* Hotfix to take users to the links they clicked instead of the dashboard

26.10.0 (2026-05-07)
====================

* OSF4I In-progress SSO Project - FE Piece

26.9.2 (2026-05-06)
===================

* Hotfix to avoid errors on creating preprint versions

26.9.1 (2026-04-28)
===================

Expand Down
48 changes: 24 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "osf",
"version": "26.9.1",
"version": "26.10.1",
"scripts": {
"ng": "ng",
"analyze-bundle": "ng build --configuration=analyze-bundle && source-map-explorer dist/**/*.js --no-border-checks",
Expand Down
33 changes: 29 additions & 4 deletions src/app/core/interceptors/error.interceptor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Router } from '@angular/router';
import { SENTRY_TOKEN } from '@core/provider/sentry.provider';
import { AuthService } from '@core/services/auth.service';
import { MaintenanceModeService } from '@core/services/maintenance-mode.service';
import { UserSelectors } from '@core/store/user';
import { ToastService } from '@osf/shared/services/toast.service';
import { ViewOnlyLinkHelperService } from '@osf/shared/services/view-only-link-helper.service';

Expand All @@ -22,6 +23,7 @@ import {
} from '@testing/providers/maintenance-mode.service.mock';
import { RouterMockBuilder, RouterMockType } from '@testing/providers/router-provider.mock';
import { SentryMock, SentryMockType } from '@testing/providers/sentry-provider.mock';
import { provideMockStore } from '@testing/providers/store-provider.mock';
import { ToastServiceMock, ToastServiceMockType } from '@testing/providers/toast-provider.mock';
import { ViewOnlyLinkHelperMock, ViewOnlyLinkHelperMockType } from '@testing/providers/view-only-link-helper.mock';

Expand All @@ -37,7 +39,12 @@ describe('errorInterceptor', () => {
let viewOnlyHelperMock: ViewOnlyLinkHelperMockType;
let sentryMock: SentryMockType;

function setup(platformId: 'browser' | 'server' = 'browser', viewOnly = false, routerUrl = '/dashboard') {
function setup(
platformId: 'browser' | 'server' = 'browser',
viewOnly = false,
routerUrl = '/dashboard',
isAuthenticated = false
) {
router = RouterMockBuilder.create().withUrl(routerUrl).withNavigate(vi.fn().mockResolvedValue(true)).build();
toastServiceMock = ToastServiceMock.simple();
loaderServiceMock = new LoaderServiceMock();
Expand All @@ -50,6 +57,9 @@ describe('errorInterceptor', () => {
providers: [
provideOSFCore(),
provideLoaderServiceMock(loaderServiceMock),
provideMockStore({
selectors: [{ selector: UserSelectors.isAuthenticated, value: isAuthenticated }],
}),
MockProvider(Router, router),
MockProvider(ToastService, toastServiceMock),
MockProvider(AuthService, authServiceMock),
Expand Down Expand Up @@ -115,15 +125,30 @@ describe('errorInterceptor', () => {
expect(toastServiceMock.showError).not.toHaveBeenCalled();
});

it('should logout on 401 in browser when not view-only', async () => {
setup('browser', false);
it('should navigate to sign in on 401 in browser when anonymous and not view-only', async () => {
setup('browser', false, '/dashboard', false);
const request = createRequest('/api/v2/nodes/abc');
const error = new HttpErrorResponse({ status: 401, error: {}, url: request.url });

const caught = await runInterceptor(request, error);

expect(caught?.status).toBe(401);
expect(authServiceMock.navigateToSignIn).toHaveBeenCalled();
expect(authServiceMock.logout).not.toHaveBeenCalled();
expect(loaderServiceMock.hide).not.toHaveBeenCalled();
expect(toastServiceMock.showError).not.toHaveBeenCalled();
});

it('should logout on 401 in browser when authenticated and not view-only', async () => {
setup('browser', false, '/dashboard', true);
const request = createRequest('/api/v2/nodes/abc');
const error = new HttpErrorResponse({ status: 401, error: {}, url: request.url });

const caught = await runInterceptor(request, error);

expect(caught?.status).toBe(401);
expect(authServiceMock.logout).toHaveBeenCalled();
expect(authServiceMock.logout).toHaveBeenCalledWith(window.location.href);
expect(authServiceMock.navigateToSignIn).not.toHaveBeenCalled();
expect(loaderServiceMock.hide).not.toHaveBeenCalled();
expect(toastServiceMock.showError).not.toHaveBeenCalled();
});
Expand Down
10 changes: 9 additions & 1 deletion src/app/core/interceptors/error.interceptor.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Store } from '@ngxs/store';

import { throwError } from 'rxjs';
import { catchError } from 'rxjs/operators';

Expand All @@ -11,6 +13,7 @@ import { MaintenanceResponse } from '@core/models/maintenance-response.model';
import { SENTRY_TOKEN } from '@core/provider/sentry.provider';
import { AuthService } from '@core/services/auth.service';
import { MaintenanceModeService } from '@core/services/maintenance-mode.service';
import { UserSelectors } from '@core/store/user';
import { LoaderService } from '@osf/shared/services/loader.service';
import { ToastService } from '@osf/shared/services/toast.service';
import { ViewOnlyLinkHelperService } from '@osf/shared/services/view-only-link-helper.service';
Expand All @@ -26,6 +29,7 @@ export const errorInterceptor: HttpInterceptorFn = (req, next) => {
const sentry = inject(SENTRY_TOKEN);
const platformId = inject(PLATFORM_ID);
const viewOnlyHelper = inject(ViewOnlyLinkHelperService);
const store = inject(Store);

return next(req).pipe(
catchError((error: HttpErrorResponse) => {
Expand Down Expand Up @@ -69,7 +73,11 @@ export const errorInterceptor: HttpInterceptorFn = (req, next) => {
if (error.status === 401) {
if (!viewOnlyHelper.hasViewOnlyParam(router)) {
if (isPlatformBrowser(platformId)) {
authService.logout();
if (store.selectSnapshot(UserSelectors.isAuthenticated)) {
authService.logout(window.location.href);
} else {
authService.navigateToSignIn();
}
}
}
return throwError(() => error);
Expand Down
12 changes: 9 additions & 3 deletions src/app/core/services/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,14 @@ export class AuthService {
}

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

const serviceUrl = new URL(`${this.webUrl}/login`);
serviceUrl.searchParams.set('next', window.location.href);

const loginUrl = new URL(`${this.casUrl}/login`);
loginUrl.searchParams.set('service', serviceUrl.toString());

window.location.href = loginUrl.toString();
}

navigateToOrcidSignIn(): void {
Expand Down Expand Up @@ -79,7 +85,7 @@ export class AuthService {

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ export class PreprintDetailsComponent implements OnInit, OnDestroy {
const preprint = this.preprint();
if (!preprint) return false;

return this.hasAdminAccess() && preprint.datePublished && preprint.isLatestVersion;
const preprintIsRejected = preprint.reviewsState === ReviewsState.Rejected;

return this.hasAdminAccess() && (preprint.datePublished || preprintIsRejected) && preprint.isLatestVersion;
});

editButtonVisible = computed(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ describe('ProfileInformationComponent', () => {
},
institutionalRequestAccessEnabled: true,
logoPath: 'logo.png',
sso_availability: 'Public',
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ describe('AddComponentDialogComponent', () => {
assets: { logo: '', logo_rounded: '', banner: '' },
institutionalRequestAccessEnabled: false,
logoPath: '',
sso_availability: 'Public',
},
{
id: 'inst-2',
Expand All @@ -76,6 +77,7 @@ describe('AddComponentDialogComponent', () => {
assets: { logo: '', logo_rounded: '', banner: '' },
institutionalRequestAccessEnabled: false,
logoPath: '',
sso_availability: 'Public',
},
];

Expand All @@ -91,6 +93,7 @@ describe('AddComponentDialogComponent', () => {
assets: { logo: '', logo_rounded: '', banner: '' },
institutionalRequestAccessEnabled: false,
logoPath: '',
sso_availability: 'Public',
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ describe('AffiliatedInstitutionSelectComponent', () => {
},
institutionalRequestAccessEnabled: false,
logoPath: '/logos/unavailable.png',
sso_availability: 'Unavailable',
};

fixture.componentRef.setInput('institutions', mockInstitutions);
Expand Down Expand Up @@ -134,6 +135,7 @@ describe('AffiliatedInstitutionSelectComponent', () => {
},
institutionalRequestAccessEnabled: false,
logoPath: '/logos/unavailable.png',
sso_availability: 'Unavailable',
};

fixture.componentRef.setInput('institutions', mockInstitutions);
Expand Down Expand Up @@ -181,6 +183,7 @@ describe('AffiliatedInstitutionSelectComponent', () => {
},
institutionalRequestAccessEnabled: false,
logoPath: '/logos/unavailable.png',
sso_availability: 'Unavailable',
};

fixture.componentRef.setInput('institutions', mockInstitutions);
Expand Down
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
1 change: 1 addition & 0 deletions src/testing/mocks/institution.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ export const MOCK_INSTITUTION = {
},
institutionalRequestAccessEnabled: true,
logoPath: 'https://mockinstitution.org/logo.png',
sso_availability: 'Public',
};
Loading