diff --git a/src/public/app/widgets/type_widgets/options/multi_factor_authentication.js b/src/public/app/widgets/type_widgets/options/multi_factor_authentication.js
index ceac5d2e3..a081f4701 100644
--- a/src/public/app/widgets/type_widgets/options/multi_factor_authentication.js
+++ b/src/public/app/widgets/type_widgets/options/multi_factor_authentication.js
@@ -20,22 +20,22 @@ const TPL = `
OpenID is a standardized way to let you log into websites using an account from another service, like Google, to verify your identity.
- Enable TOTP
+ TOTP Enabled
@@ -62,24 +62,24 @@ const TPL = `
- Recover Key 1
+
- Recover Key 2
+
- Recover Key 3
+
- Recover Key 4
+
- Recover Key 5
+
- Recover Key 6
+
- Recover Key 7
+
- Recover Key 8
+
@@ -94,7 +94,6 @@ export default class MultiFactorAuthenticationOptions extends OptionsWidget {
this.$widget = $(TPL);
this.$regenerateTotpButton = this.$widget.find(".regenerate-totp");
- this.$totpDetails = this.$widget.find(".totp-details");
this.$totpEnabled = this.$widget.find(".totp-enabled");
this.$totpSecret = this.$widget.find(".totp-secret");
this.$totpSecretInput = this.$widget.find(".totp-secret-input");
@@ -103,7 +102,6 @@ export default class MultiFactorAuthenticationOptions extends OptionsWidget {
".generate-recovery-code"
);
this.$oAuthEnabledCheckbox = this.$widget.find(".oauth-enabled-checkbox");
- this.$clearSavedUserButton = this.$widget.find(".clear-saved-user-button");
this.$oauthLoginButton = this.$widget.find(".oauth-login-button");
this.$UserAccountName = this.$widget.find(".user-account-name");
this.$UserAccountEmail = this.$widget.find(".user-account-email");
@@ -114,17 +112,9 @@ export default class MultiFactorAuthenticationOptions extends OptionsWidget {
this.$recoveryKeys = [];
for (let i = 0; i < 8; i++)
+ {
this.$recoveryKeys.push(this.$widget.find(".key_" + i));
-
- // Depricated. Will use .env to control.
- // this.$totpEnabled.on("change", async () => {
- // this.updateSecret();
- // });
-
- // Depricated. Will use .env to control.
- // this.$oAuthEnabledCheckbox.on("change", async () => {
- // this.updateOAuthStatus();
- // });
+ }
this.$generateRecoveryCodeButton.on("click", async () => {
this.setRecoveryKeys();
@@ -134,18 +124,6 @@ export default class MultiFactorAuthenticationOptions extends OptionsWidget {
this.generateKey();
});
- this.$clearSavedUserButton.on("click", (async) => {
- server
- .get("oauth/clearUser")
- .then((result) => {
- toastService.showMessage(result.message);
- })
- .catch((result) => {
- console.error(result.message);
- toastService.showError(result.message);
- });
- });
-
this.$protectedSessionTimeout = this.$widget.find(
".protected-session-timeout-in-seconds"
);
@@ -155,28 +133,6 @@ export default class MultiFactorAuthenticationOptions extends OptionsWidget {
this.$protectedSessionTimeout.val()
)
);
-
- this.displayRecoveryKeys();
- }
-
- // Depricated. Will use .env to control.
- // async updateSecret() {
- // if (this.$totpEnabled.prop("checked")) {
- // server.post("totp/enable");
-
- // }
- // else {
- // server.post("totp/disable");
- // }
- // }
-
- async updateOAuthStatus() {
- if (this.$oAuthEnabledCheckbox.prop("checked")){
- server.post("oauth/enable");
- }
- else{
- server.post("oauth/disable");
- }
}
async setRecoveryKeys() {
@@ -214,61 +170,30 @@ export default class MultiFactorAuthenticationOptions extends OptionsWidget {
server.get("oauth/status").then((result) => {
if (result.enabled) {
- // if (result.success)
this.$oAuthEnabledCheckbox.prop("checked", result.enabled);
-
- // this.$oauthLoginButton.prop("disabled", !result.message);
- // this.$saveUserButton.prop("disabled", !result.message);
-
- // if (result.message) {
- // this.$oauthLoginButton.prop("disabled", false);
- // this.$saveUserButton.prop("disabled", false);
- // server.get("oauth/validate").then((result) => {
- // if (result.success) {
- this.$UserAccountName.text(result.name);
- this.$UserAccountEmail.text(result.email);
-
- // if (result.user) {
- // this.$userStatus.text("User saved!");
- // } else {
- // this.$saveUserButton.prop("disabled", false);
- // this.$userStatus.text("User not saved");
- // }
- // } else this.$tokenStatus.text("Not logged in!");
- // });
- // }
- // } else {
- // this.$oAuthEnabledCheckbox.prop("checked", false);
- // this.$oauthLoginButton.prop("disabled", true);
- // this.$saveUserButton.prop("disabled", true);
- // this.$oAuthEnabledCheckbox.prop("disabled", true);
-
- // this.$envEnabledOAuth.text(
- // "OAuth can only be enabled with environment variables. REQUIRES RESTART"
- // );
- }
+ this.$UserAccountName.text(result.name);
+ this.$UserAccountEmail.text(result.email);
+ }else
+ this.$envEnabledOAuth.text(
+ "set OAUTH_ENABLED as environment variable to 'true' to enable (Requires restart)"
+ );
});
server.get("totp/status").then((result) => {
- console.log(result);
- if (result.enabled)
- if (result.success) {
+ if (result.enabled){
this.$totpEnabled.prop("checked", result.message);
- this.$totpSecretInput.prop("disabled", !result.message);
this.$authenticatorCode.prop("disabled", !result.message);
this.$generateRecoveryCodeButton.prop("disabled", !result.message);
- } else {
- toastService.showError(result.message);
- }
+ this.displayRecoveryKeys();
+ }
else {
this.$totpEnabled.prop("checked", false);
this.$totpEnabled.prop("disabled", true);
- this.$totpSecretInput.prop("disabled", true);
this.$authenticatorCode.prop("disabled", true);
this.$generateRecoveryCodeButton.prop("disabled", true);
this.$envEnabledTOTP.text(
- "TOTP_ENABLED is set as environment variable to enable (Requires restart)"
+ "Set TOTP_ENABLED as environment variable to 'true' to enable (Requires restart)"
);
}
});
diff --git a/src/routes/routes.ts b/src/routes/routes.ts
index 844f995a8..d6f2024ea 100644
--- a/src/routes/routes.ts
+++ b/src/routes/routes.ts
@@ -129,7 +129,6 @@ function register(app: express.Application) {
apiRoute(GET, '/api/totp/get', totp.getSecret);
apiRoute(GET, '/api/oauth/status', openID.getOAuthStatus);
- apiRoute(GET, '/api/oauth/clearUser', openID.clearSavedUser);
apiRoute(GET, '/api/oauth/validate', openID.isTokenValid);
apiRoute(PST, '/api/totp_recovery/set', recoveryCodes.setRecoveryCodes);