diff --git a/jslib b/jslib
index 3cb94623..52cc6405 160000
--- a/jslib
+++ b/jslib
@@ -1 +1 @@
-Subproject commit 3cb94623e2c6a3ac6cf6dbcd516ba23b03a7aee7
+Subproject commit 52cc64053760100662c99bd57ac413acbd3a1c1b
diff --git a/src/app/organizations/settings/two-factor-setup.component.ts b/src/app/organizations/settings/two-factor-setup.component.ts
index 12675fcf..a8566e12 100644
--- a/src/app/organizations/settings/two-factor-setup.component.ts
+++ b/src/app/organizations/settings/two-factor-setup.component.ts
@@ -3,7 +3,10 @@ import { ActivatedRoute } from "@angular/router";
import { ModalService } from "jslib-angular/services/modal.service";
import { ApiService } from "jslib-common/abstractions/api.service";
+import { I18nService } from "jslib-common/abstractions/i18n.service";
+import { LogService } from "jslib-common/abstractions/log.service";
import { MessagingService } from "jslib-common/abstractions/messaging.service";
+import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
import { PolicyService } from "jslib-common/abstractions/policy.service";
import { StateService } from "jslib-common/abstractions/state.service";
import { TwoFactorProviderType } from "jslib-common/enums/twoFactorProviderType";
@@ -22,9 +25,21 @@ export class TwoFactorSetupComponent extends BaseTwoFactorSetupComponent {
messagingService: MessagingService,
policyService: PolicyService,
private route: ActivatedRoute,
- stateService: StateService
+ stateService: StateService,
+ platformUtilsService: PlatformUtilsService,
+ i18nService: I18nService,
+ logService: LogService
) {
- super(apiService, modalService, messagingService, policyService, stateService);
+ super(
+ apiService,
+ modalService,
+ messagingService,
+ policyService,
+ stateService,
+ platformUtilsService,
+ i18nService,
+ logService
+ );
}
async ngOnInit() {
diff --git a/src/app/settings/two-factor-setup.component.html b/src/app/settings/two-factor-setup.component.html
index 549636f8..6d95419c 100644
--- a/src/app/settings/two-factor-setup.component.html
+++ b/src/app/settings/two-factor-setup.component.html
@@ -55,6 +55,40 @@
+
diff --git a/src/app/settings/two-factor-setup.component.ts b/src/app/settings/two-factor-setup.component.ts
index bab25942..6c3df0f3 100644
--- a/src/app/settings/two-factor-setup.component.ts
+++ b/src/app/settings/two-factor-setup.component.ts
@@ -3,11 +3,15 @@ import { Component, OnInit, Type, ViewChild, ViewContainerRef } from "@angular/c
import { ModalRef } from "jslib-angular/components/modal/modal.ref";
import { ModalService } from "jslib-angular/services/modal.service";
import { ApiService } from "jslib-common/abstractions/api.service";
+import { I18nService } from "jslib-common/abstractions/i18n.service";
+import { LogService } from "jslib-common/abstractions/log.service";
import { MessagingService } from "jslib-common/abstractions/messaging.service";
+import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
import { PolicyService } from "jslib-common/abstractions/policy.service";
import { StateService } from "jslib-common/abstractions/state.service";
import { PolicyType } from "jslib-common/enums/policyType";
import { TwoFactorProviderType } from "jslib-common/enums/twoFactorProviderType";
+import { DeviceVerificationRequest } from "jslib-common/models/request/DeviceVerificationRequest";
import { TwoFactorProviders } from "jslib-common/services/twoFactor.service";
import { TwoFactorAuthenticatorComponent } from "./two-factor-authenticator.component";
@@ -39,18 +43,32 @@ export class TwoFactorSetupComponent implements OnInit {
canAccessPremium: boolean;
showPolicyWarning = false;
loading = true;
+ enableDeviceVerification: boolean;
+ isDeviceVerificationSectionEnabled: boolean;
modal: ModalRef;
+ formPromise: Promise;
constructor(
protected apiService: ApiService,
protected modalService: ModalService,
protected messagingService: MessagingService,
protected policyService: PolicyService,
- private stateService: StateService
+ private stateService: StateService,
+ private platformUtilsService: PlatformUtilsService,
+ private i18nService: I18nService,
+ private logService: LogService
) {}
async ngOnInit() {
this.canAccessPremium = await this.stateService.getCanAccessPremium();
+ try {
+ const deviceVerificationSettings = await this.apiService.getDeviceVerificationSettings();
+ this.isDeviceVerificationSectionEnabled =
+ deviceVerificationSettings.isDeviceVerificationSectionEnabled;
+ this.enableDeviceVerification = deviceVerificationSettings.unknownDeviceVerificationEnabled;
+ } catch (e) {
+ this.logService.error(e);
+ }
for (const key in TwoFactorProviders) {
// eslint-disable-next-line
@@ -186,4 +204,20 @@ export class TwoFactorSetupComponent implements OnInit {
this.showPolicyWarning = false;
}
}
+
+ async submit() {
+ try {
+ this.formPromise = this.apiService.putDeviceVerificationSettings(
+ new DeviceVerificationRequest(this.enableDeviceVerification)
+ );
+ await this.formPromise;
+ this.platformUtilsService.showToast(
+ "success",
+ null,
+ this.i18nService.t("updatedDeviceVerification")
+ );
+ } catch (e) {
+ this.logService.error(e);
+ }
+ }
}
diff --git a/src/locales/en/messages.json b/src/locales/en/messages.json
index bb37b09b..7ae62031 100644
--- a/src/locales/en/messages.json
+++ b/src/locales/en/messages.json
@@ -5069,5 +5069,17 @@
},
"apiAccessToken": {
"message": "API Access Token"
+ },
+ "deviceVerification": {
+ "message": "Device Verification"
+ },
+ "enableDeviceVerification": {
+ "message": "Enable Device Verification"
+ },
+ "deviceVerificationDesc": {
+ "message": "When enabled, verification codes are sent to your email address when logging in from an unrecognized device"
+ },
+ "updatedDeviceVerification": {
+ "message": "Updated Device Verification"
}
}