import { Injectable } from '@angular/core' ; import { ActivatedRouteSnapshot , RouterStateSnapshot , UrlTree , CanActivate , Router } from '@angular/router' ; import { CurrentAccountService } from '@shared/services/current-account.service' ; import { GlobalService } from '@shared/services/global.service' ; @ Injectable ( { providedIn : 'root' } ) export class AccountSelectedGuard implements CanActivate { constructor ( private router , private globalService , private currentAccountService ) { } canActivate ( next , state ) { if ( ! this . globalService . getSidechainEnabled ( ) ) { return false ; } const accountsEnabled = this . currentAccountService . hasActiveAddress ( ) ; if ( ! accountsEnabled ) { this . router . navigate ( [ '/address-selection' ] ) ; return false ; } return true ; } }