Skip to content
This repository has been archived by the owner on Apr 12, 2021. It is now read-only.

Commit

Permalink
feat(app): #1638 added auth resolver in sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
webkhushboo committed Jan 12, 2020
1 parent 1d28882 commit f80f993
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 14 deletions.
35 changes: 22 additions & 13 deletions web/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,32 @@ import { NgModule } from '@angular/core';

// Dashboard hub core modules
import { RouterModule, Routes } from '@angular/router';
import { AuthResolver } from '@core/resolvers/auth.resolver';
import { SidebarComponent } from './shared/components/sidebar/sidebar.component';

const routes: Routes = [
{
path: '',
loadChildren: './main/main.module#MainModule',
},
{
path: 'projects',
loadChildren: './projects/projects.module#ProjectsModule',
},
{
path: 'admin',
loadChildren: './admin/admin.module#AdminModule',
},
{
path: '**',
loadChildren: './error/error.module#ErrorModule',
component: SidebarComponent,
resolve: [AuthResolver],
children: [
{
path: '',
loadChildren: './main/main.module#MainModule',
},
{
path: 'projects',
loadChildren: './projects/projects.module#ProjectsModule',
},
{
path: 'admin',
loadChildren: './admin/admin.module#AdminModule',
},
{
path: '**',
loadChildren: './error/error.module#ErrorModule',
},
],
},
];

Expand Down
2 changes: 1 addition & 1 deletion web/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<dashboard-sidebar></dashboard-sidebar>
<router-outlet></router-outlet>
28 changes: 28 additions & 0 deletions web/src/app/core/resolvers/auth.resolver.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Core modules
import { Injectable } from '@angular/core';

// DashboardHub services
import { AuthenticationService } from '../services/index.service';

// Dashboard hub model and services

@Injectable({
providedIn: 'root',
})
export class AuthResolver {

/**
* Life cycle method
* @param authService AuthenticationService
*/
constructor(
private authService: AuthenticationService
) { }

/**
* Get the current user and check if authenticated or not
*/
resolve(): void {
return this.authService.checkAuth();
}
}

0 comments on commit f80f993

Please sign in to comment.