mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
[ACS-8726] Use functional route guards (#4096)
* [ACS-8726] Use functional route guards * [ACS-8726] reduce duplication
This commit is contained in:
committed by
GitHub
parent
49cd06d2f9
commit
3a2d870db1
@@ -22,22 +22,16 @@
|
||||
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CanActivate } from '@angular/router';
|
||||
import { Observable } from 'rxjs';
|
||||
import { inject } from '@angular/core';
|
||||
import { CanActivateFn } from '@angular/router';
|
||||
import { AuthenticationService } from '@alfresco/adf-core';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ViewProfileRuleGuard implements CanActivate {
|
||||
constructor(private authService: AuthenticationService) {}
|
||||
export const ViewProfileRuleGuard: CanActivateFn = () => {
|
||||
const authService = inject(AuthenticationService);
|
||||
|
||||
canActivate(): Observable<boolean> | Promise<boolean> | boolean {
|
||||
return this.isEcmLoggedIn() || this.authService.isOauth();
|
||||
}
|
||||
const isEcmLoggedIn = (): boolean => {
|
||||
return authService.isEcmLoggedIn() || (authService.isECMProvider() && authService.isKerberosEnabled());
|
||||
};
|
||||
|
||||
private isEcmLoggedIn(): boolean {
|
||||
return this.authService.isEcmLoggedIn() || (this.authService.isECMProvider() && this.authService.isKerberosEnabled());
|
||||
}
|
||||
}
|
||||
return isEcmLoggedIn() || authService.isOauth();
|
||||
};
|
||||
|
Reference in New Issue
Block a user