From 671056ddd9bd0fe851609a8f6d96e03e13bcd01e Mon Sep 17 00:00:00 2001 From: Dmitry Nehaychik <4dmitr@gmail.com> Date: Wed, 2 Aug 2017 18:13:50 +0300 Subject: [PATCH] refactor(auth): move auth into core module --- src/app/@core/core.module.ts | 17 +++++++++++++++++ src/app/app-routing.module.ts | 28 ++++++++++++++-------------- src/app/app.module.ts | 15 --------------- src/app/pages/pages-menu.ts | 2 +- 4 files changed, 32 insertions(+), 30 deletions(-) diff --git a/src/app/@core/core.module.ts b/src/app/@core/core.module.ts index b11c96ea..792bba74 100644 --- a/src/app/@core/core.module.ts +++ b/src/app/@core/core.module.ts @@ -1,17 +1,34 @@ import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core'; import { CommonModule } from '@angular/common'; +import { NbAuthModule, NbDummyAuthProvider } from '@nebular/auth'; import { throwIfAlreadyLoaded } from './module-import-guard'; import { DataModule } from './data/data.module'; const NB_CORE_PROVIDERS = [ ...DataModule.forRoot().providers, + ...NbAuthModule.forRoot({ + providers: { + email: { + service: NbDummyAuthProvider, + config: { + delay: 1000, + login: { + rememberMe: true, + }, + }, + }, + }, + }).providers, ]; @NgModule({ imports: [ CommonModule, ], + exports: [ + NbAuthModule, + ], declarations: [], }) export class CoreModule { diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 35429f3a..5490a21c 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -1,43 +1,43 @@ import { ExtraOptions, RouterModule, Routes } from '@angular/router'; import { NgModule } from '@angular/core'; import { - NgaAuthComponent, - NgaLoginComponent, - NgaLogoutComponent, - NgaRegisterComponent, - NgaRequestPasswordComponent, - NgaResetPasswordComponent -} from '@akveo/nga-auth'; + NbAuthComponent, + NbLoginComponent, + NbLogoutComponent, + NbRegisterComponent, + NbRequestPasswordComponent, + NbResetPasswordComponent, +} from '@nebular/auth'; const routes: Routes = [ { path: 'pages', loadChildren: 'app/pages/pages.module#PagesModule' }, { path: 'auth', - component: NgaAuthComponent, + component: NbAuthComponent, children: [ { path: '', - component: NgaLoginComponent, + component: NbLoginComponent, }, { path: 'login', - component: NgaLoginComponent, + component: NbLoginComponent, }, { path: 'register', - component: NgaRegisterComponent, + component: NbRegisterComponent, }, { path: 'logout', - component: NgaLogoutComponent, + component: NbLogoutComponent, }, { path: 'request-password', - component: NgaRequestPasswordComponent, + component: NbRequestPasswordComponent, }, { path: 'reset-password', - component: NgaResetPasswordComponent, + component: NbResetPasswordComponent, }, ], }, diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 8af3fe71..da03e45b 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -8,7 +8,6 @@ import { BrowserModule } from '@angular/platform-browser'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { NgModule } from '@angular/core'; import { HttpModule } from '@angular/http'; -import { NgaAuthModule, NgaDummyAuthProvider } from '@akveo/nga-auth'; import { CoreModule } from './@core/core.module'; import { AppComponent } from './app.component'; @@ -25,20 +24,6 @@ import { ThemeModule } from './@theme/theme.module'; CoreModule, ThemeModule.forRoot(), CoreModule.forRoot(), - NgaAuthModule, - NgaAuthModule.forRoot({ - providers: { - email: { - service: NgaDummyAuthProvider, - config: { - delay: 1000, - login: { - rememberMe: true, - } - }, - }, - } - }), ], bootstrap: [AppComponent], providers: [ diff --git a/src/app/pages/pages-menu.ts b/src/app/pages/pages-menu.ts index 3e46c83a..7481e321 100644 --- a/src/app/pages/pages-menu.ts +++ b/src/app/pages/pages-menu.ts @@ -102,7 +102,7 @@ export const MENU_ITEMS: List = List([{ }, { title: 'Auth', icon: 'ion-unlocked', - children: List([{ + children: List([{ title: 'Login', link: '/auth/login', }, {