import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { AuthGuard, AuthUpdateGuard, AuthenticatedGuard, AnonymousGuard } from './auth/auth.guard'; import { HomeComponent } from './pages/home/home.component'; import { LoginComponent } from './pages/login/login.component'; import { FormLoginComponent } from './pages/form-login/form-login.component'; import { PasswordComponent } from './pages/password/password.component'; import { AccountComponent } from './pages/account/account.component'; import { RegisterComponent } from './pages/register/register.component'; import { TokensComponent } from './pages/tokens/tokens.component'; import { AppsComponent } from './pages/apps/apps.component'; import { InfoComponent } from './pages/account/info/info.component'; import { VoucherComponent } from './pages/account/voucher/voucher.component'; import { SecurityComponent } from './pages/account/security/security.component'; import { UnavailableComponent } from './pages/unavailable/unavailable.component'; import { NotfoundComponent } from './pages/notfound/notfound.component'; const routes: Routes = [ { path: '', component: HomeComponent, canActivate: [AuthUpdateGuard], pathMatch: 'full', runGuardsAndResolvers: 'always' }, { path: 'login', component: LoginComponent, canActivate: [AnonymousGuard] }, { path: 'external-login', component: FormLoginComponent, canActivate: [AnonymousGuard] }, { path: 'password', component: PasswordComponent, canActivate: [AnonymousGuard] }, { path: 'apps', component: AppsComponent, canActivate: [AuthenticatedGuard] }, { path: 'account', component: AccountComponent, canActivate: [AuthenticatedGuard], children: [ { path: 'info', component: InfoComponent, canActivate: [AuthenticatedGuard] }, { path: 'voucher', component: VoucherComponent, canActivate: [AuthenticatedGuard] }, { path: 'security', component: SecurityComponent, canActivate: [AuthenticatedGuard] } ] }, { path: 'register', component: RegisterComponent, canActivate: [AnonymousGuard] }, { path: 'tokens', component: TokensComponent, canActivate: [AuthGuard] }, { path: 'unavailable', component: UnavailableComponent }, { path: '**', component: NotfoundComponent, pathMatch: 'full' }, ]; @NgModule({ imports: [RouterModule.forRoot(routes, { onSameUrlNavigation: 'reload' })], exports: [RouterModule] }) export class AppRoutingModule { }