mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-21 13:55:51 +00:00
add show total users in rocket chat server
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { HomeGuard } from './home.guard';
|
||||
|
||||
describe('HomeGuard', () => {
|
||||
let guard: HomeGuard;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
guard = TestBed.inject(HomeGuard);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(guard).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,32 @@
|
||||
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);
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { IndexGuard } from './index.guard';
|
||||
|
||||
describe('IndexGuard', () => {
|
||||
let guard: IndexGuard;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
guard = TestBed.inject(IndexGuard);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(guard).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,31 @@
|
||||
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 IndexGuard 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){
|
||||
this.router.navigate(['home']);
|
||||
resolve(false);
|
||||
}
|
||||
else{
|
||||
resolve(true);
|
||||
}
|
||||
}).catch(err =>{
|
||||
resolve(false);
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user