Demo shell improvements (#1199)

* #1197 auth guards

* #1197 restore lost router dependency to all libs

* #1197 ecm/bpm auth guards, home page

- ECM auth guard (redirect to Login if ECM auth is missing)
- BPM auth guard (redirect to Login if BPM auth is missing)
- new Home page and route, show details on demo areas

* css improvements

make app text white as per request
This commit is contained in:
Denys Vuika
2016-12-03 18:57:43 +00:00
committed by Eugenio Romano
parent 3a288c6b1b
commit 800a2a6530
29 changed files with 432 additions and 28 deletions

View File

@@ -29,7 +29,10 @@ import {
AlfrescoTranslationService,
AlfrescoAuthenticationService,
AlfrescoContentService,
RenditionsService
RenditionsService,
AuthGuard,
AuthGuardEcm,
AuthGuardBpm
} from './src/services/index';
import { MATERIAL_DESIGN_DIRECTIVES } from './src/components/material/index';
@@ -48,6 +51,9 @@ export const ALFRESCO_CORE_PROVIDERS: any[] = [
AlfrescoTranslationLoader,
AlfrescoTranslationService,
RenditionsService,
AuthGuard,
AuthGuardEcm,
AuthGuardBpm,
...CONTEXT_MENU_PROVIDERS
];

View File

@@ -0,0 +1,53 @@
/*!
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Injectable } from '@angular/core';
import {
CanActivate, Router, CanActivateChild,
ActivatedRouteSnapshot,
RouterStateSnapshot
} from '@angular/router';
import { AlfrescoAuthenticationService } from './AlfrescoAuthentication.service';
@Injectable()
export class AuthGuardBpm implements CanActivate, CanActivateChild {
constructor(private authService: AlfrescoAuthenticationService, private router: Router) {}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
let url: string = state.url;
return this.checkLogin(url);
}
canActivateChild(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
return this.canActivate(route, state);
}
checkLogin(url: string): boolean {
if (this.authService.isBpmLoggedIn()) {
return true;
}
// Store the attempted URL for redirecting
// this.authService.redirectUrl = url;
// Navigate to the login page with extras
this.router.navigate(['/login']);
return false;
}
}

View File

@@ -0,0 +1,53 @@
/*!
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Injectable } from '@angular/core';
import {
CanActivate, Router, CanActivateChild,
ActivatedRouteSnapshot,
RouterStateSnapshot
} from '@angular/router';
import { AlfrescoAuthenticationService } from './AlfrescoAuthentication.service';
@Injectable()
export class AuthGuardEcm implements CanActivate, CanActivateChild {
constructor(private authService: AlfrescoAuthenticationService, private router: Router) {}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
let url: string = state.url;
return this.checkLogin(url);
}
canActivateChild(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
return this.canActivate(route, state);
}
checkLogin(url: string): boolean {
if (this.authService.isEcmLoggedIn()) {
return true;
}
// Store the attempted URL for redirecting
// this.authService.redirectUrl = url;
// Navigate to the login page with extras
this.router.navigate(['/login']);
return false;
}
}

View File

@@ -0,0 +1,53 @@
/*!
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Injectable } from '@angular/core';
import {
CanActivate, Router, CanActivateChild,
ActivatedRouteSnapshot,
RouterStateSnapshot
} from '@angular/router';
import { AlfrescoAuthenticationService } from './AlfrescoAuthentication.service';
@Injectable()
export class AuthGuard implements CanActivate, CanActivateChild {
constructor(private authService: AlfrescoAuthenticationService, private router: Router) {}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
let url: string = state.url;
return this.checkLogin(url);
}
canActivateChild(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
return this.canActivate(route, state);
}
checkLogin(url: string): boolean {
if (this.authService.isLoggedIn()) {
return true;
}
// Store the attempted URL for redirecting
// this.authService.redirectUrl = url;
// Navigate to the login page with extras
this.router.navigate(['/login']);
return false;
}
}

View File

@@ -23,3 +23,6 @@ export * from './AlfrescoTranslation.service';
export * from './AlfrescoAuthentication.service';
export * from './AlfrescoContent.service';
export * from './renditions.service';
export * from './auth-guard.service';
export * from './auth-guard-ecm.service';
export * from './auth-guard-bpm.service';