diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts
index 6b9fc55..7e65103 100644
--- a/src/app/app-routing.module.ts
+++ b/src/app/app-routing.module.ts
@@ -6,9 +6,9 @@ import { OverviewComponent } from './components/dashboard/overview/overview.comp
import { FundersComponent } from './components/funders/funders.component';
import { SmesComponent } from './components/smes/smes.component';
import { UserModule } from './components/user/user.module';
-import { SignInComponent } from './sign-in/sign-in.component';
+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 },
{
@@ -26,9 +27,11 @@ const routes: Routes = [
{ path: 'Overview', component: OverviewComponent},
{ path: 'Funders', component: FundersComponent},
- { path: 'Smes', component: SmesComponent,}]
+ { 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 aeb03a5..ec994a6 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -1,3 +1,5 @@
+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';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
@@ -16,11 +18,18 @@ import { OverviewComponent } from './components/dashboard/overview/overview.comp
import { FundersComponent } from './components/funders/funders.component';
import { SmesComponent } from './components/smes/smes.component';
import { FooterComponent } from './components/footer/footer.component';
-import { SignInComponent } from './sign-in/sign-in.component';
+import { SignInComponent } from './components/sign-in/sign-in.component';
+import { StoreModule } from '@ngrx/store';
+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, 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';
import { SmesDashboardComponent } from './components/smes-dashboard/smes-dashboard.component';
import { NavbarComponent } from './shared/components/navbar/navbar.component';
-import { SideNavService } from './shared/services/side-nav.service';
import { SideNavComponent } from './shared/components/side-nav/side-nav.component';
@@ -49,10 +58,26 @@ import { SideNavComponent } from './shared/components/side-nav/side-nav.componen
MatSidenavModule,
MatToolbarModule,
MatButtonModule,
- MatIconModule
+ MatIconModule,
+ HttpClientModule,
+ StoreModule.forRoot(authReducers, {}),
+ EffectsModule.forRoot([AuthEffects]),
+ StoreDevtoolsModule.instrument({ maxAge: 25, logOnly: environment.production }),
],
- providers: [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 @@
-