mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 05:16:07 +00:00
33 lines
844 B
TypeScript
33 lines
844 B
TypeScript
import { Injectable } from '@angular/core';
|
|
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree, Router } from '@angular/router';
|
|
import { Observable } from 'rxjs';
|
|
import { AuthConnstants } from '../config/auth-constants';
|
|
import { StorageService } from '../services/storage.service';
|
|
|
|
@Injectable({
|
|
providedIn: 'root'
|
|
})
|
|
export class HomeGuard implements CanActivate {
|
|
constructor(
|
|
public storageService:StorageService,
|
|
private router:Router
|
|
){}
|
|
|
|
canActivate(): Promise<boolean>{
|
|
return new Promise(resolve => {
|
|
/* this.storageService.get(AuthConnstants.AUTH).then(res => {
|
|
if(res){
|
|
resolve(true);
|
|
}
|
|
else{
|
|
this.router.navigate(['']);
|
|
resolve(false);
|
|
}
|
|
}).catch(err =>{
|
|
resolve(false);
|
|
}) */
|
|
});
|
|
}
|
|
|
|
}
|