forked from DSpace/dspace-angular
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged in dspacecris7-DSC-280 (pull request #40)
[DSC-280] Allow to turnoff completely the end user agreement (cherry-pick from CST-4803) Approved-by: Giuseppe Digilio
- Loading branch information
Showing
8 changed files
with
81 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 9 additions & 4 deletions
13
src/app/core/end-user-agreement/end-user-agreement-cookie.guard.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,30 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { AbstractEndUserAgreementGuard } from './abstract-end-user-agreement.guard'; | ||
import { Observable, of as observableOf } from 'rxjs'; | ||
import { Observable } from 'rxjs'; | ||
import { EndUserAgreementService } from './end-user-agreement.service'; | ||
import { Router } from '@angular/router'; | ||
import { map } from 'rxjs/operators'; | ||
|
||
/** | ||
* A guard redirecting users to the end agreement page when the user agreement cookie hasn't been accepted | ||
*/ | ||
@Injectable() | ||
export class EndUserAgreementCookieGuard extends AbstractEndUserAgreementGuard { | ||
|
||
constructor(protected endUserAgreementService: EndUserAgreementService, | ||
protected router: Router) { | ||
constructor( | ||
protected endUserAgreementService: EndUserAgreementService, | ||
protected router: Router, | ||
) { | ||
super(router); | ||
} | ||
|
||
/** | ||
* True when the user agreement cookie has been accepted | ||
*/ | ||
hasAccepted(): Observable<boolean> { | ||
return observableOf(this.endUserAgreementService.isCookieAccepted()); | ||
return this.endUserAgreementService.isUserAgreementEnabled().pipe( | ||
map((isUserAgreementEnabled) => isUserAgreementEnabled ? this.endUserAgreementService.isCookieAccepted() : true), | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 11 additions & 4 deletions
15
src/app/core/end-user-agreement/end-user-agreement-current-user.guard.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,32 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { Observable } from 'rxjs'; | ||
import { Observable, of } from 'rxjs'; | ||
import { AbstractEndUserAgreementGuard } from './abstract-end-user-agreement.guard'; | ||
import { EndUserAgreementService } from './end-user-agreement.service'; | ||
import { Router } from '@angular/router'; | ||
import { switchMap } from 'rxjs/operators'; | ||
|
||
/** | ||
* A guard redirecting logged in users to the end agreement page when they haven't accepted the latest user agreement | ||
*/ | ||
@Injectable() | ||
export class EndUserAgreementCurrentUserGuard extends AbstractEndUserAgreementGuard { | ||
|
||
constructor(protected endUserAgreementService: EndUserAgreementService, | ||
protected router: Router) { | ||
constructor( | ||
protected endUserAgreementService: EndUserAgreementService, | ||
protected router: Router, | ||
) { | ||
super(router); | ||
} | ||
|
||
/** | ||
* True when the currently logged in user has accepted the agreements or when the user is not currently authenticated | ||
*/ | ||
hasAccepted(): Observable<boolean> { | ||
return this.endUserAgreementService.hasCurrentUserAcceptedAgreement(true); | ||
return this.endUserAgreementService.isUserAgreementEnabled().pipe( | ||
switchMap((isUserAgreementEnabled) => isUserAgreementEnabled ? | ||
this.endUserAgreementService.hasCurrentUserAcceptedAgreement(true) : of(true) | ||
), | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters