File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { NgModule } from '@angular/core' ;
22import { RouterModule , Routes } from '@angular/router' ;
33import { AuthGuard } from './guards/auth.guard' ;
4+ import { DevOnlyGuard } from './guards/dev-only.guard' ;
45
56const routes : Routes = [
67 {
@@ -29,7 +30,8 @@ const routes: Routes = [
2930 } ,
3031 {
3132 path : 'devtool' ,
32- loadChildren : ( ) => import ( './pages/devtool/devtool.module' ) . then ( m => m . DevtoolPageModule )
33+ loadChildren : ( ) => import ( './pages/devtool/devtool.module' ) . then ( m => m . DevtoolPageModule ) ,
34+ canLoad : [ DevOnlyGuard ] ,
3335 } ,
3436 {
3537 path : '' ,
Original file line number Diff line number Diff line change 1+ import { Injectable } from '@angular/core' ;
2+ import { CanLoad , Router } from '@angular/router' ;
3+ import { environment } from '@v3/environments/environment' ;
4+
5+ @Injectable ( {
6+ providedIn : 'root'
7+ } )
8+ export class DevOnlyGuard implements CanLoad {
9+ constructor (
10+ private router : Router
11+ ) { }
12+
13+ canLoad ( ) : boolean {
14+ const isLive = environment . production ;
15+ if ( isLive === true ) {
16+ this . router . navigate ( [ '/' ] ) ;
17+ return false ;
18+ }
19+ return true ;
20+ }
21+ }
You can’t perform that action at this time.
0 commit comments