mirror of https://github.com/abpframework/abp.git
2 changed files with 124 additions and 0 deletions
@ -0,0 +1,92 @@ |
|||
import { |
|||
authGuard, |
|||
ReplaceableComponents, |
|||
ReplaceableRouteContainerComponent, |
|||
RouterOutletComponent, |
|||
} from '@abp/ng.core'; |
|||
|
|||
import { ForgotPasswordComponent } from './components/forgot-password/forgot-password.component'; |
|||
import { LoginComponent } from './components/login/login.component'; |
|||
import { ManageProfileComponent } from './components/manage-profile/manage-profile.component'; |
|||
import { RegisterComponent } from './components/register/register.component'; |
|||
import { ResetPasswordComponent } from './components/reset-password/reset-password.component'; |
|||
import { eAccountComponents } from './enums/components'; |
|||
import { authenticationFlowGuard } from './guards'; |
|||
import { accountExtensionsResolver } from './resolvers'; |
|||
import { provideAccount } from './account'; |
|||
|
|||
const canActivate = [authenticationFlowGuard]; |
|||
|
|||
export const accountRoutes = [ |
|||
{ |
|||
path: '', |
|||
component: RouterOutletComponent, |
|||
providers: [...provideAccount()], |
|||
children: [ |
|||
{ path: '', pathMatch: 'full', redirectTo: 'login' }, |
|||
{ |
|||
path: 'login', |
|||
component: ReplaceableRouteContainerComponent, |
|||
canActivate, |
|||
data: { |
|||
replaceableComponent: { |
|||
key: eAccountComponents.Login, |
|||
defaultComponent: LoginComponent, |
|||
} as ReplaceableComponents.RouteData<LoginComponent>, |
|||
}, |
|||
title: 'AbpAccount::Login', |
|||
}, |
|||
{ |
|||
path: 'register', |
|||
component: ReplaceableRouteContainerComponent, |
|||
canActivate, |
|||
data: { |
|||
replaceableComponent: { |
|||
key: eAccountComponents.Register, |
|||
defaultComponent: RegisterComponent, |
|||
} as ReplaceableComponents.RouteData<RegisterComponent>, |
|||
}, |
|||
title: 'AbpAccount::Register', |
|||
}, |
|||
{ |
|||
path: 'forgot-password', |
|||
component: ReplaceableRouteContainerComponent, |
|||
canActivate, |
|||
|
|||
data: { |
|||
replaceableComponent: { |
|||
key: eAccountComponents.ForgotPassword, |
|||
defaultComponent: ForgotPasswordComponent, |
|||
} as ReplaceableComponents.RouteData<ForgotPasswordComponent>, |
|||
}, |
|||
title: 'AbpAccount::ForgotPassword', |
|||
}, |
|||
{ |
|||
path: 'reset-password', |
|||
component: ReplaceableRouteContainerComponent, |
|||
canActivate: [], |
|||
data: { |
|||
tenantBoxVisible: false, |
|||
replaceableComponent: { |
|||
key: eAccountComponents.ResetPassword, |
|||
defaultComponent: ResetPasswordComponent, |
|||
} as ReplaceableComponents.RouteData<ResetPasswordComponent>, |
|||
}, |
|||
title: 'AbpAccount::ResetPassword', |
|||
}, |
|||
{ |
|||
path: 'manage', |
|||
component: ReplaceableRouteContainerComponent, |
|||
canActivate: [authGuard], |
|||
resolve: [accountExtensionsResolver], |
|||
data: { |
|||
replaceableComponent: { |
|||
key: eAccountComponents.ManageProfile, |
|||
defaultComponent: ManageProfileComponent, |
|||
} as ReplaceableComponents.RouteData<ManageProfileComponent>, |
|||
}, |
|||
title: 'AbpAccount::MyAccount', |
|||
}, |
|||
], |
|||
}, |
|||
]; |
|||
@ -0,0 +1,32 @@ |
|||
import { importProvidersFrom } from '@angular/core'; |
|||
import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap'; |
|||
import { NgxValidateCoreModule } from '@ngx-validate/core'; |
|||
import { AccountConfigOptions } from './models/config-options'; |
|||
import { ACCOUNT_CONFIG_OPTIONS } from './tokens/config-options.token'; |
|||
import { accountConfigOptionsFactory } from './utils/factory-utils'; |
|||
import { AuthenticationFlowGuard } from './guards/authentication-flow.guard'; |
|||
import { RE_LOGIN_CONFIRMATION_TOKEN } from './tokens'; |
|||
import { ACCOUNT_EDIT_FORM_PROP_CONTRIBUTORS } from './tokens/extensions.token'; |
|||
import { AccountExtensionsGuard } from './guards/extensions.guard'; |
|||
|
|||
export function provideAccount(options: AccountConfigOptions = {}) { |
|||
return [ |
|||
importProvidersFrom(NgbDropdownModule, NgxValidateCoreModule), |
|||
AuthenticationFlowGuard, |
|||
{ provide: ACCOUNT_CONFIG_OPTIONS, useValue: options }, |
|||
{ |
|||
provide: 'ACCOUNT_OPTIONS', |
|||
useFactory: accountConfigOptionsFactory, |
|||
deps: [ACCOUNT_CONFIG_OPTIONS], |
|||
}, |
|||
{ |
|||
provide: RE_LOGIN_CONFIRMATION_TOKEN, |
|||
useValue: options.isPersonalSettingsChangedConfirmationActive ?? true, |
|||
}, |
|||
{ |
|||
provide: ACCOUNT_EDIT_FORM_PROP_CONTRIBUTORS, |
|||
useValue: options.editFormPropContributors, |
|||
}, |
|||
AccountExtensionsGuard, |
|||
]; |
|||
} |
|||
Loading…
Reference in new issue