Skip to content

Commit b14a5bc

Browse files
authored
Merge pull request #2341 from intersective/prerelease
Release 2.4.2.2
2 parents 7fbc103 + 129fbe8 commit b14a5bc

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

projects/v3/src/app/app-routing.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { NgModule } from '@angular/core';
22
import { RouterModule, Routes } from '@angular/router';
33
import { AuthGuard } from './guards/auth.guard';
4+
import { DevOnlyGuard } from './guards/dev-only.guard';
45

56
const 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: '',
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
}

0 commit comments

Comments
 (0)