diff --git a/jslib b/jslib index f4ed6a55..e555536f 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit f4ed6a5566b49e1a7175d931408bbe14e4dc0af7 +Subproject commit e555536f2413927508db91affa371560ba633c88 diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 5c158b3c..e5d37e59 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -28,6 +28,9 @@ import { PeopleComponent as OrgPeopleComponent } from './organizations/manage/pe import { AccountComponent as OrgAccountComponent } from './organizations/settings/account.component'; import { OrganizationBillingComponent } from './organizations/settings/organization-billing.component'; import { SettingsComponent as OrgSettingsComponent } from './organizations/settings/settings.component'; +import { + TwoFactorSetupComponent as OrgTwoFactorSetupComponent, +} from './organizations/settings/two-factor-setup.component'; import { ExportComponent as OrgExportComponent } from './organizations/tools/export.component'; import { ImportComponent as OrgImportComponent } from './organizations/tools/import.component'; @@ -188,6 +191,7 @@ const routes: Routes = [ children: [ { path: '', pathMatch: 'full', redirectTo: 'account' }, { path: 'account', component: OrgAccountComponent, data: { titleId: 'myOrganization' } }, + { path: 'two-factor', component: OrgTwoFactorSetupComponent, data: { titleId: 'twoStepLogin' } }, { path: 'billing', component: OrganizationBillingComponent, diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 411fd5a7..6fcc342a 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -56,6 +56,9 @@ import { AdjustSeatsComponent } from './organizations/settings/adjust-seats.comp import { DeleteOrganizationComponent } from './organizations/settings/delete-organization.component'; import { OrganizationBillingComponent } from './organizations/settings/organization-billing.component'; import { SettingsComponent as OrgSettingComponent } from './organizations/settings/settings.component'; +import { + TwoFactorSetupComponent as OrgTwoFactorSetupComponent, +} from './organizations/settings/two-factor-setup.component'; import { ExportComponent as OrgExportComponent } from './organizations/tools/export.component'; import { ImportComponent as OrgImportComponent } from './organizations/tools/import.component'; @@ -210,6 +213,7 @@ import { SearchPipe } from 'jslib/angular/pipes/search.pipe'; OrgPeopleComponent, OrgSettingComponent, OrgToolsComponent, + OrgTwoFactorSetupComponent, OrgUserAddEditComponent, OrgUserGroupsComponent, OrganizationsComponent, diff --git a/src/app/organizations/settings/settings.component.html b/src/app/organizations/settings/settings.component.html index 9f413ab2..68836cea 100644 --- a/src/app/organizations/settings/settings.component.html +++ b/src/app/organizations/settings/settings.component.html @@ -10,6 +10,9 @@ {{'billingAndLicensing' | i18n}} + + {{'twoStepLogin' | i18n}} + diff --git a/src/app/organizations/settings/settings.component.ts b/src/app/organizations/settings/settings.component.ts index ccaf24b3..33abd223 100644 --- a/src/app/organizations/settings/settings.component.ts +++ b/src/app/organizations/settings/settings.component.ts @@ -1,7 +1,21 @@ import { Component } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +import { UserService } from 'jslib/abstractions/user.service'; @Component({ selector: 'app-org-settings', templateUrl: 'settings.component.html', }) -export class SettingsComponent { } +export class SettingsComponent { + access2fa = false; + + constructor(private route: ActivatedRoute, private userService: UserService) { } + + ngOnInit() { + this.route.parent.params.subscribe(async (params) => { + const organization = await this.userService.getOrganization(params.organizationId); + this.access2fa = organization.use2fa; + }); + } +} diff --git a/src/app/organizations/settings/two-factor-setup.component.ts b/src/app/organizations/settings/two-factor-setup.component.ts new file mode 100644 index 00000000..9ea0bef5 --- /dev/null +++ b/src/app/organizations/settings/two-factor-setup.component.ts @@ -0,0 +1,58 @@ +import { + Component, + ComponentFactoryResolver, +} from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +import { ApiService } from 'jslib/abstractions/api.service'; +import { MessagingService } from 'jslib/abstractions/messaging.service'; +import { TokenService } from 'jslib/abstractions/token.service'; + +import { TwoFactorProviderType } from 'jslib/enums/twoFactorProviderType'; + +import { TwoFactorDuoComponent } from '../../settings/two-factor-duo.component'; +import { TwoFactorSetupComponent as BaseTwoFactorSetupComponent } from '../../settings/two-factor-setup.component'; + +@Component({ + selector: 'app-two-factor-setup', + templateUrl: '../../settings/two-factor-setup.component.html', +}) +export class TwoFactorSetupComponent extends BaseTwoFactorSetupComponent { + organizationId: string; + + constructor(apiService: ApiService, tokenService: TokenService, + componentFactoryResolver: ComponentFactoryResolver, messagingService: MessagingService, + private route: ActivatedRoute) { + super(apiService, tokenService, componentFactoryResolver, messagingService); + } + + async ngOnInit() { + this.route.parent.parent.params.subscribe(async (params) => { + this.organizationId = params.organizationId; + await super.ngOnInit(); + }); + } + + manage(type: TwoFactorProviderType) { + switch (type) { + case TwoFactorProviderType.OrganizationDuo: + const duoComp = this.openModal(this.duoModalRef, TwoFactorDuoComponent); + duoComp.type = TwoFactorProviderType.OrganizationDuo; + duoComp.organizationId = this.organizationId; + duoComp.onUpdated.subscribe((enabled: boolean) => { + this.updateStatus(enabled, TwoFactorProviderType.OrganizationDuo); + }); + break; + default: + break; + } + } + + protected getTwoFactorProviders() { + return this.apiService.getTwoFactorOrganizationProviders(this.organizationId); + } + + protected filterProvider(type: TwoFactorProviderType) { + return type !== TwoFactorProviderType.OrganizationDuo; + } +} diff --git a/src/app/settings/two-factor-authenticator.component.html b/src/app/settings/two-factor-authenticator.component.html index f75a519b..0eb2b054 100644 --- a/src/app/settings/two-factor-authenticator.component.html +++ b/src/app/settings/two-factor-authenticator.component.html @@ -10,7 +10,7 @@ - +
- + - + - + - + - +