@@ -47,6 +47,7 @@ export const bitstreamDownloadRedirectGuard: CanActivateFn = (
4747) : Observable < UrlTree | boolean > => {
4848
4949 const bitstreamId = route . params . id ;
50+ const accessToken : string = route . queryParams . accessToken ;
5051
5152 return bitstreamDataService . findById ( bitstreamId , true , false , ...BITSTREAM_PAGE_LINKS_TO_FOLLOW ) . pipe (
5253 getFirstCompletedRemoteData ( ) ,
@@ -79,14 +80,21 @@ export const bitstreamDownloadRedirectGuard: CanActivateFn = (
7980 if ( isAuthorized && isLoggedIn && isNotEmpty ( fileLink ) ) {
8081 hardRedirectService . redirect ( fileLink ) ;
8182 return false ;
82- } else if ( isAuthorized && ! isLoggedIn ) {
83+ } else if ( isAuthorized && ! isLoggedIn && ! hasValue ( accessToken ) ) {
8384 hardRedirectService . redirect ( bitstream . _links . content . href ) ;
8485 return false ;
85- } else if ( ! isAuthorized && isLoggedIn ) {
86- return router . createUrlTree ( [ getForbiddenRoute ( ) ] ) ;
87- } else if ( ! isAuthorized && ! isLoggedIn ) {
88- auth . setRedirectUrl ( router . url ) ;
89- return router . createUrlTree ( [ 'login' ] ) ;
86+ } else if ( ! isAuthorized ) {
87+ // Either we have an access token, or we are logged in, or we are not logged in.
88+ // For now, the access token does not care if we are logged in or not.
89+ if ( hasValue ( accessToken ) ) {
90+ hardRedirectService . redirect ( bitstream . _links . content . href + '?accessToken=' + accessToken ) ;
91+ return false ;
92+ } else if ( isLoggedIn ) {
93+ return router . createUrlTree ( [ getForbiddenRoute ( ) ] ) ;
94+ } else if ( ! isLoggedIn ) {
95+ auth . setRedirectUrl ( router . url ) ;
96+ return router . createUrlTree ( [ 'login' ] ) ;
97+ }
9098 }
9199 } ) ,
92100 ) ;
0 commit comments