mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-12 17:04:46 +00:00
ACA-4615 : Restrict Edit Profile functionality to ECM users only (#2662)
* ACA-4615 Restrict Edit Profile functionality to ECM users only
This commit is contained in:
parent
9cf9fa01f9
commit
dc215dc034
@ -39,6 +39,7 @@ import { SharedFilesComponent } from './components/shared-files/shared-files.com
|
||||
import { DetailsComponent } from './components/details/details.component';
|
||||
import { HomeComponent } from './components/home/home.component';
|
||||
import { ViewProfileComponent } from './components/view-profile/view-profile.component';
|
||||
import { ViewProfileRuleGuard } from './components/view-profile/view-profile.guard';
|
||||
|
||||
export const APP_ROUTES: Routes = [
|
||||
{
|
||||
@ -79,6 +80,7 @@ export const APP_ROUTES: Routes = [
|
||||
children: [
|
||||
{
|
||||
path: 'profile',
|
||||
canActivate: [ViewProfileRuleGuard],
|
||||
component: ViewProfileComponent
|
||||
},
|
||||
{
|
||||
|
27
app/src/app/components/view-profile/view-profile.guard.ts
Normal file
27
app/src/app/components/view-profile/view-profile.guard.ts
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright © 2005 - 2021 Alfresco Software, Ltd. All rights reserved.
|
||||
*
|
||||
* License rights for this program may be obtained from Alfresco Software, Ltd.
|
||||
* pursuant to a written agreement and any use of this program without such an
|
||||
* agreement is prohibited.
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CanActivate, ActivatedRouteSnapshot } from '@angular/router';
|
||||
import { Observable } from 'rxjs';
|
||||
import { AuthenticationService } from '@alfresco/adf-core';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ViewProfileRuleGuard implements CanActivate {
|
||||
constructor(private authService: AuthenticationService) {}
|
||||
|
||||
canActivate(_: ActivatedRouteSnapshot): Observable<boolean> | Promise<boolean> | boolean {
|
||||
return this.isEcmLoggedIn() && !this.authService.isOauth();
|
||||
}
|
||||
|
||||
private isEcmLoggedIn() {
|
||||
return this.authService.isEcmLoggedIn() || (this.authService.isECMProvider() && this.authService.isKerberosEnabled());
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user