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:
Shubham Bansal 2022-09-22 17:00:29 +00:00 committed by GitHub
parent 9cf9fa01f9
commit dc215dc034
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 0 deletions

View File

@ -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
},
{

View 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());
}
}