diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts
index 1069d2a..7e65103 100644
--- a/src/app/app-routing.module.ts
+++ b/src/app/app-routing.module.ts
@@ -8,7 +8,7 @@ import { SmesComponent } from './components/smes/smes.component';
import { UserModule } from './components/user/user.module';
import { SignInComponent } from './components/sign-in/sign-in.component';
import { SmesDashboardComponent } from './components/smes-dashboard/smes-dashboard.component';
-
+import { AuthGuardService as AuthGuard } from './services/auth-guard.service';
const routes: Routes = [
{
@@ -17,7 +17,8 @@ const routes: Routes = [
},
{
path: 'smes-dashboard',
- component: SmesDashboardComponent
+ component: SmesDashboardComponent,
+ canActivate: [AuthGuard]
},
{ path: 'user', loadChildren: () => UserModule },
{
@@ -29,7 +30,8 @@ const routes: Routes = [
{ path: 'Smes', component: SmesComponent},
]
},
- { path: 'sign-in', component: SignInComponent}
+ { path: 'sign-in', component: SignInComponent},
+ { path: '**', redirectTo: '/' }
];
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 21ee63b..ec994a6 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -1,3 +1,4 @@
+import { TokenInterceptor, ErrorInterceptor } from './services/token.interceptor';
import { SideNavService } from './shared/services/side-nav.service';
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
@@ -23,7 +24,7 @@ import { AuthService } from './services/auth.service';
import { authReducers } from './store/state/user.state';
import { EffectsModule } from '@ngrx/effects';
import { AuthEffects } from './store/effects/auth.effects';
-import { HttpClientModule } from '@angular/common/http';
+import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
import { StoreDevtoolsModule } from '@ngrx/store-devtools';
import { environment } from '../environments/environment';
import { SideNavTogglerComponent } from './shared/components/side-nav-toggler/side-nav-toggler.component';
@@ -64,7 +65,19 @@ import { SideNavComponent } from './shared/components/side-nav/side-nav.componen
StoreDevtoolsModule.instrument({ maxAge: 25, logOnly: environment.production }),
],
- providers: [AuthService, SideNavService],
+ providers: [
+ AuthService, SideNavService,
+ {
+ provide: HTTP_INTERCEPTORS,
+ useClass: TokenInterceptor,
+ multi: true
+ },
+ {
+ provide: HTTP_INTERCEPTORS,
+ useClass: ErrorInterceptor,
+ multi: true
+ }
+ ],
bootstrap: [AppComponent]
})
diff --git a/src/app/components/home-page/home-page.component.html b/src/app/components/home-page/home-page.component.html
index cb188f0..6a74a6b 100644
--- a/src/app/components/home-page/home-page.component.html
+++ b/src/app/components/home-page/home-page.component.html
@@ -1,35 +1,35 @@
-