bitwarden-estensione-browser/src/app/app-routing.module.ts

126 lines
5.6 KiB
TypeScript
Raw Normal View History

2018-06-05 05:10:41 +02:00
import { NgModule } from '@angular/core';
import {
RouterModule,
Routes,
} from '@angular/router';
2018-06-08 23:08:19 +02:00
import { FrontendLayoutComponent } from './layouts/frontend-layout.component';
import { OrganizationLayoutComponent } from './layouts/organization-layout.component';
import { UserLayoutComponent } from './layouts/user-layout.component';
2018-06-05 21:02:53 +02:00
import { HintComponent } from './accounts/hint.component';
import { LockComponent } from './accounts/lock.component';
2018-06-05 21:02:53 +02:00
import { LoginComponent } from './accounts/login.component';
import { RegisterComponent } from './accounts/register.component';
import { TwoFactorComponent } from './accounts/two-factor.component';
2018-07-05 20:40:53 +02:00
import { ExportComponent as OrgExportComponent } from './organizations/tools/export.component';
import { ToolsComponent as OrgToolsComponent } from './organizations/tools/tools.component';
import { VaultComponent as OrgVaultComponent } from './organizations/vault/vault.component';
2018-07-03 18:34:20 +02:00
2018-06-21 04:27:37 +02:00
import { AccountComponent } from './settings/account.component';
2018-07-02 23:09:53 +02:00
import { CreateOrganizationComponent } from './settings/create-organization.component';
2018-06-26 05:16:59 +02:00
import { DomainRulesComponent } from './settings/domain-rules.component';
2018-06-25 22:44:06 +02:00
import { OptionsComponent } from './settings/options.component';
import { OrganizationsComponent } from './settings/organizations.component';
import { PremiumComponent } from './settings/premium.component';
2018-06-21 04:27:37 +02:00
import { SettingsComponent } from './settings/settings.component';
2018-06-27 04:51:58 +02:00
import { TwoFactorSetupComponent } from './settings/two-factor-setup.component';
2018-06-28 20:05:04 +02:00
import { UserBillingComponent } from './settings/user-billing.component';
2018-06-21 04:27:37 +02:00
2018-06-28 17:58:33 +02:00
import { BreachReportComponent } from './tools/breach-report.component';
2018-06-10 05:33:12 +02:00
import { ExportComponent } from './tools/export.component';
import { ImportComponent } from './tools/import.component';
2018-06-21 00:16:20 +02:00
import { PasswordGeneratorComponent } from './tools/password-generator.component';
2018-06-10 05:33:12 +02:00
import { ToolsComponent } from './tools/tools.component';
2018-06-05 05:10:41 +02:00
import { VaultComponent } from './vault/vault.component';
2018-07-05 21:27:23 +02:00
import { OrganizationGuardService } from './services/organization-guard.service';
import { OrganizationTypeGuardService } from './services/organization-type-guard.service';
2018-06-10 04:02:45 +02:00
import { UnauthGuardService } from './services/unauth-guard.service';
import { AuthGuardService } from 'jslib/angular/services/auth-guard.service';
2018-07-05 21:27:23 +02:00
import { OrganizationUserType } from 'jslib/enums/organizationUserType';
2018-06-05 05:10:41 +02:00
const routes: Routes = [
{
2018-06-08 23:08:19 +02:00
path: '',
2018-06-10 04:02:45 +02:00
component: FrontendLayoutComponent,
2018-06-08 23:08:19 +02:00
children: [
2018-06-10 04:02:45 +02:00
{ path: '', pathMatch: 'full', component: LoginComponent, canActivate: [UnauthGuardService] },
{ path: '2fa', component: TwoFactorComponent, canActivate: [UnauthGuardService] },
{ path: 'register', component: RegisterComponent, canActivate: [UnauthGuardService] },
{ path: 'hint', component: HintComponent, canActivate: [UnauthGuardService] },
{ path: 'lock', component: LockComponent },
2018-06-08 23:08:19 +02:00
],
},
{
path: '',
2018-06-10 04:02:45 +02:00
component: UserLayoutComponent,
2018-07-05 21:27:23 +02:00
canActivate: [AuthGuardService],
2018-06-08 23:08:19 +02:00
children: [
2018-07-05 21:27:23 +02:00
{ path: 'vault', component: VaultComponent },
2018-06-21 04:27:37 +02:00
{
path: 'settings',
component: SettingsComponent,
children: [
{ path: '', pathMatch: 'full', redirectTo: 'account' },
2018-07-05 21:27:23 +02:00
{ path: 'account', component: AccountComponent },
{ path: 'options', component: OptionsComponent },
{ path: 'domain-rules', component: DomainRulesComponent },
{ path: 'two-factor', component: TwoFactorSetupComponent },
{ path: 'premium', component: PremiumComponent },
{ path: 'billing', component: UserBillingComponent },
{ path: 'organizations', component: OrganizationsComponent },
{ path: 'create-organization', component: CreateOrganizationComponent },
2018-06-21 04:27:37 +02:00
],
},
2018-06-10 05:33:12 +02:00
{
path: 'tools',
component: ToolsComponent,
2018-07-05 21:27:23 +02:00
canActivate: [AuthGuardService],
2018-06-10 05:33:12 +02:00
children: [
2018-06-21 00:16:20 +02:00
{ path: '', pathMatch: 'full', redirectTo: 'generator' },
2018-07-05 21:27:23 +02:00
{ path: 'import', component: ImportComponent },
{ path: 'export', component: ExportComponent },
{ path: 'generator', component: PasswordGeneratorComponent },
{ path: 'breach-report', component: BreachReportComponent },
2018-06-10 05:33:12 +02:00
],
},
2018-06-08 23:08:19 +02:00
],
},
{
2018-07-03 18:34:20 +02:00
path: 'organizations/:organizationId',
2018-06-08 23:08:19 +02:00
component: OrganizationLayoutComponent,
2018-07-05 21:27:23 +02:00
canActivate: [AuthGuardService, OrganizationGuardService],
2018-06-08 23:08:19 +02:00
children: [
2018-07-03 18:34:20 +02:00
{ path: '', pathMatch: 'full', redirectTo: 'vault' },
2018-07-05 21:27:23 +02:00
{ path: 'vault', component: OrgVaultComponent },
2018-07-05 20:40:53 +02:00
{
path: 'tools',
component: OrgToolsComponent,
2018-07-05 21:27:23 +02:00
canActivate: [OrganizationTypeGuardService],
data: { allowedTypes: [OrganizationUserType.Owner, OrganizationUserType.Admin] },
2018-07-05 20:40:53 +02:00
children: [
{ path: '', pathMatch: 'full', redirectTo: 'export' },
2018-07-05 21:27:23 +02:00
// { path: 'import', component: ImportComponent },
{ path: 'export', component: OrgExportComponent },
2018-07-05 20:40:53 +02:00
],
},
2018-06-08 23:08:19 +02:00
],
2018-06-05 05:10:41 +02:00
},
2018-06-08 23:08:19 +02:00
{ path: '**', redirectTo: '' },
2018-06-05 05:10:41 +02:00
];
@NgModule({
imports: [RouterModule.forRoot(routes, {
useHash: true,
/*enableTracing: true,*/
})],
exports: [RouterModule],
})
export class AppRoutingModule { }