mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-31 04:23:40 +00:00
nav guard added
This commit is contained in:
committed by
Aiden McClelland
parent
c17d35c83e
commit
ffd8f7b278
@@ -1,10 +1,12 @@
|
|||||||
import { NgModule } from '@angular/core'
|
import { NgModule } from '@angular/core'
|
||||||
import { PreloadAllModules, RouterModule, Routes } from '@angular/router'
|
import { PreloadAllModules, RouterModule, Routes } from '@angular/router'
|
||||||
|
import { NavGuard } from './guards/nav-guard'
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{
|
{
|
||||||
path: 'init',
|
path: 'init',
|
||||||
loadChildren: () => import('./pages/init/init.module').then( m => m.InitPageModule),
|
loadChildren: () => import('./pages/init/init.module').then( m => m.InitPageModule),
|
||||||
|
canActivate: [NavGuard],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'product-key',
|
path: 'product-key',
|
||||||
@@ -13,22 +15,27 @@ const routes: Routes = [
|
|||||||
{
|
{
|
||||||
path: 'home',
|
path: 'home',
|
||||||
loadChildren: () => import('./pages/home/home.module').then( m => m.HomePageModule),
|
loadChildren: () => import('./pages/home/home.module').then( m => m.HomePageModule),
|
||||||
|
canActivate: [NavGuard],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'recover',
|
path: 'recover',
|
||||||
loadChildren: () => import('./pages/recover/recover.module').then( m => m.RecoverPageModule),
|
loadChildren: () => import('./pages/recover/recover.module').then( m => m.RecoverPageModule),
|
||||||
|
canActivate: [NavGuard],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'embassy',
|
path: 'embassy',
|
||||||
loadChildren: () => import('./pages/embassy/embassy.module').then( m => m.EmbassyPageModule),
|
loadChildren: () => import('./pages/embassy/embassy.module').then( m => m.EmbassyPageModule),
|
||||||
|
canActivate: [NavGuard],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'loading',
|
path: 'loading',
|
||||||
loadChildren: () => import('./pages/loading/loading.module').then( m => m.LoadingPageModule),
|
loadChildren: () => import('./pages/loading/loading.module').then( m => m.LoadingPageModule),
|
||||||
|
canActivate: [NavGuard],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'success',
|
path: 'success',
|
||||||
loadChildren: () => import('./pages/success/success.module').then( m => m.SuccessPageModule),
|
loadChildren: () => import('./pages/success/success.module').then( m => m.SuccessPageModule),
|
||||||
|
canActivate: [NavGuard],
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
22
setup-wizard/src/app/guards/nav-guard.ts
Normal file
22
setup-wizard/src/app/guards/nav-guard.ts
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import { Injectable } from '@angular/core'
|
||||||
|
import { CanActivate, Router } from '@angular/router'
|
||||||
|
import { HttpService } from '../services/api/http.service'
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root',
|
||||||
|
})
|
||||||
|
export class NavGuard implements CanActivate {
|
||||||
|
constructor (
|
||||||
|
private readonly router: Router,
|
||||||
|
private readonly httpService: HttpService,
|
||||||
|
) { }
|
||||||
|
|
||||||
|
canActivate (): boolean {
|
||||||
|
if (this.httpService.productKey) {
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
this.router.navigateByUrl('product-key')
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,4 +18,8 @@ import { SuccessPageRoutingModule } from './success-routing.module'
|
|||||||
],
|
],
|
||||||
declarations: [SuccessPage],
|
declarations: [SuccessPage],
|
||||||
})
|
})
|
||||||
export class SuccessPageModule { }
|
export class SuccessPageModule {
|
||||||
|
constructor () {
|
||||||
|
console.log('SuccessModule loaded.')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user