我有以下路线规则:
CREATE OR REPLACE TRIGGER FECHASALIDA
BEFORE INSERT ON EXPEDIENTES
FOR EACH ROW
BEGIN
IF (:NEW.FECHAINGRESO>:NEW.FECHASALIDA)
THEN RAISE_APPLICATION_ERROR (-20600,:NEW.FECHASALIDA||'No se puede dar una fecha de salida anterior a la del ingreso');
END IF;
END;
如何禁止使用开放的特定路径路径,如:
path: 'school', component: ShellComponent, canActivate: [AuthenticationGuard],
children: [
{path: 'education/documents', component: DocumentsComponent}]
如果使用角色管理员或其他?
使用像{path: 'education/documents', component: DocumentsComponent}]
答案 0 :(得分:1)
创建Gaurd文件,您可以根据自己的要求进行更新
import {Injectable} from '@angular/core';
import {CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot} from '@angular/router';
import {Observable} from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class AuthGuard implements CanActivate {
constructor(private helper: HelperService, private auth: AuthService) { }
canActivate(
next: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean> | Promise<boolean> | boolean {
if (this.auth.isLoggedIn) {
// logged in so return true
return true;
}
// not logged in so redirect to login page with the return url
this.helper.redirect('/');
return false;
}
}
在路线文件中使用保护:
{path: 'account',component: AccountComponent,canActivate: [AuthGuard]},
children: [
{
path: 'account',
component: AccountComponent,
canActivate: [AuthGuard]
}
]