diff --git a/src/app/bitstream-page/clarin-bitstream-download-page/clarin-bitstream-download-page.component.spec.ts b/src/app/bitstream-page/clarin-bitstream-download-page/clarin-bitstream-download-page.component.spec.ts index d5931835c93..d57dc32873f 100644 --- a/src/app/bitstream-page/clarin-bitstream-download-page/clarin-bitstream-download-page.component.spec.ts +++ b/src/app/bitstream-page/clarin-bitstream-download-page/clarin-bitstream-download-page.component.spec.ts @@ -211,14 +211,15 @@ describe('ClarinBitstreamDownloadPageComponent', () => { expect(component.redirectToContent).not.toHaveBeenCalled(); }); - it('should download with the dtoken and the access token once the CLARIN check passes', () => { + it('should redirect an anonymous user through HardRedirectService with the dtoken and the access token once the CLARIN check passes', () => { rdbService.buildFromRequestUUID.and.returnValue(of(createSuccessfulRemoteDataObject({}))); activatedRoute.snapshot.queryParams = { dtoken: dtoken, accessToken: accessToken }; component.ngOnInit(); - expect(component.redirectToContent).toHaveBeenCalledWith( + expect(hardRedirectService.redirect).toHaveBeenCalledWith( contentHref + '?dtoken=' + dtoken + '&accessToken=' + accessToken); + expect(component.redirectToContent).not.toHaveBeenCalled(); }); it('should download through the file link with the access token for a logged-in user', () => { @@ -266,7 +267,8 @@ describe('ClarinBitstreamDownloadPageComponent', () => { component.ngOnInit(); expect(clarinCheckUrl()).toEqual('rest-api/authrn/bitstreamUuid?dtoken=' + dtoken); - expect(component.redirectToContent).toHaveBeenCalledWith(contentHref + '?dtoken=' + dtoken); + expect(hardRedirectService.redirect).toHaveBeenCalledWith(contentHref + '?dtoken=' + dtoken); + expect(component.redirectToContent).not.toHaveBeenCalled(); }); it('should send an anonymous user without an access token to the login page', () => { diff --git a/src/app/bitstream-page/clarin-bitstream-download-page/clarin-bitstream-download-page.component.ts b/src/app/bitstream-page/clarin-bitstream-download-page/clarin-bitstream-download-page.component.ts index 9252abab9bc..7ef032a3007 100644 --- a/src/app/bitstream-page/clarin-bitstream-download-page/clarin-bitstream-download-page.component.ts +++ b/src/app/bitstream-page/clarin-bitstream-download-page/clarin-bitstream-download-page.component.ts @@ -172,7 +172,9 @@ export class ClarinBitstreamDownloadPageComponent implements OnInit { this.redirectToContent(fileLink); } else if ((isAuthorized || isAuthorizedByClarin) && !isLoggedIn) { this.downloadStatus.next(RequestEntryState.Success); - this.redirectToContent(bitstreamURL); + // Server-side too, so crawlers get a 302. Logged-in users keep the client-side + // redirect: a server 302 right after login left the browser on the login page. + this.hardRedirectService.redirect(bitstreamURL); } else if (!(isAuthorized || isAuthorizedByClarin) && isLoggedIn && this.downloadStatus.value === (RequestEntryState.Error as string)) { // this.downloadStatus is `ERROR` - no CLARIN exception is thrown up