31 lines
845 B
TypeScript
31 lines
845 B
TypeScript
|
|
import { Injectable } from "@angular/core";
|
||
|
|
import {
|
||
|
|
CanActivate,
|
||
|
|
ActivatedRouteSnapshot,
|
||
|
|
RouterStateSnapshot,
|
||
|
|
} from "@angular/router";
|
||
|
|
import { Observable } from "rxjs/Observable";
|
||
|
|
import { Router } from "@angular/router";
|
||
|
|
@Injectable()
|
||
|
|
export class DbauthGuard implements CanActivate {
|
||
|
|
constructor(private router: Router) {}
|
||
|
|
canActivate(
|
||
|
|
next: ActivatedRouteSnapshot,
|
||
|
|
state: RouterStateSnapshot
|
||
|
|
): Observable<boolean> | Promise<boolean> | boolean {
|
||
|
|
if (
|
||
|
|
window.location.origin.match(/nipponsecura.in/g) != null &&
|
||
|
|
state.url == "/add_newDevice"
|
||
|
|
) {
|
||
|
|
this.router.navigateByUrl("add_newDevice2");
|
||
|
|
} else if (
|
||
|
|
window.location.origin.match(/nipponsecura.in/g) != null &&
|
||
|
|
state.url == "/editDevice"
|
||
|
|
) {
|
||
|
|
this.router.navigateByUrl("db_editDevice");
|
||
|
|
}
|
||
|
|
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
}
|