created auth to check if cards are set
This commit is contained in:
parent
1df3eb3d5e
commit
eb074c00ae
@ -1,5 +1,6 @@
|
|||||||
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 { AuthGuard } from './services/values.auth';
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{
|
{
|
||||||
@ -12,11 +13,11 @@ const routes: Routes = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'valuesSorting',
|
path: 'valuesSorting',
|
||||||
loadChildren: () => import('./valuesSorting/valuesSorting.module').then( m => m.ValuesSortingPageModule)
|
loadChildren: () => import('./valuesSorting/valuesSorting.module').then( m => m.ValuesSortingPageModule), canActivate: [AuthGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'valuesAlign',
|
path: 'valuesAlign',
|
||||||
loadChildren: () => import('./valuesAlign/valuesAlign.module').then( m => m.ValuesAlignPageModule)
|
loadChildren: () => import('./valuesAlign/valuesAlign.module').then( m => m.ValuesAlignPageModule), canActivate: [AuthGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '',
|
path: '',
|
||||||
|
20
AuthentesApp/src/app/services/values.auth.ts
Normal file
20
AuthentesApp/src/app/services/values.auth.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { CanActivate, Router } from '@angular/router';
|
||||||
|
import { GameService } from './game.service';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
|
||||||
|
export class AuthGuard implements CanActivate {
|
||||||
|
constructor(private router: Router, private game: GameService) {}
|
||||||
|
async canActivate(){
|
||||||
|
if(this.game.cardset.length > 0){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// no cards so redirect to the homepage
|
||||||
|
this.router.navigate(['/home']);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user