mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 18:12:29 +08:00
feat: 🎸 Disable MFA on electron instance
This commit is contained in:
parent
0741c8546f
commit
647226858d
@ -3,8 +3,9 @@ import toastService from "../../../services/toast.js";
|
||||
import OptionsWidget from "./options_widget.js";
|
||||
import type { OptionMap } from "../../../../../services/options_interface.js";
|
||||
import { t } from "../../../services/i18n.js";
|
||||
import utils from "../../../services/utils.js";
|
||||
|
||||
const TPL = `
|
||||
const TPL_WEB = `
|
||||
<div class="options-section">
|
||||
<h4>${t("multi_factor_authentication.title")}</h4>
|
||||
<p class="form-text">${t("multi_factor_authentication.description")}</p>
|
||||
@ -102,6 +103,13 @@ const TPL = `
|
||||
</div>
|
||||
`;
|
||||
|
||||
const TPL_ELECTRON = `
|
||||
<div class="options-section">
|
||||
<h4>${t("multi_factor_authentication.title")}</h4>
|
||||
<p class="form-text">${t("multi_factor_authentication.electron_disabled")}</p>
|
||||
</div>
|
||||
`;
|
||||
|
||||
interface OAuthStatus {
|
||||
enabled: boolean;
|
||||
name?: string;
|
||||
@ -134,8 +142,10 @@ export default class MultiFactorAuthenticationOptions extends OptionsWidget {
|
||||
private $protectedSessionTimeout!: JQuery<HTMLElement>;
|
||||
|
||||
doRender() {
|
||||
this.$widget = $(TPL);
|
||||
const template = utils.isElectron() ? TPL_ELECTRON : TPL_WEB;
|
||||
this.$widget = $(template);
|
||||
|
||||
if (!utils.isElectron()) {
|
||||
this.$generateTotpButton = this.$widget.find(".generate-totp");
|
||||
this.$totpEnabled = this.$widget.find(".totp-enabled");
|
||||
this.$totpSecret = this.$widget.find(".totp-secret");
|
||||
@ -166,6 +176,7 @@ export default class MultiFactorAuthenticationOptions extends OptionsWidget {
|
||||
|
||||
this.displayRecoveryKeys();
|
||||
}
|
||||
}
|
||||
|
||||
async setRecoveryKeys() {
|
||||
const result = await server.get<RecoveryKeysResponse>("totp_recovery/generate");
|
||||
@ -231,6 +242,7 @@ export default class MultiFactorAuthenticationOptions extends OptionsWidget {
|
||||
}
|
||||
|
||||
optionsLoaded(options: OptionMap) {
|
||||
if (!utils.isElectron()) {
|
||||
server.get<OAuthStatus>("oauth/status").then((result) => {
|
||||
if (result.enabled) {
|
||||
this.$oAuthEnabledCheckbox.prop("checked", result.enabled);
|
||||
@ -264,3 +276,4 @@ export default class MultiFactorAuthenticationOptions extends OptionsWidget {
|
||||
this.$protectedSessionTimeout.val(Number(options.protectedSessionTimeout));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1302,6 +1302,7 @@
|
||||
"multi_factor_authentication": {
|
||||
"title": "多因素认证",
|
||||
"description": "多因素认证(MFA)为您的账户添加了额外的安全层。除了输入密码登录外,MFA还要求您提供一个或多个额外的验证信息来验证您的身份。这样,即使有人获得了您的密码,没有第二个验证信息他们也无法访问您的账户。这就像给您的门添加了一把额外的锁,让他人更难闯入。",
|
||||
"electron_disabled": "当前桌面版本不支持多因素认证。",
|
||||
"oauth_title": "OAuth/OpenID 认证",
|
||||
"oauth_enabled": "OAuth/OpenID 已启用",
|
||||
"oauth_enable_description": "在配置文件中设置 ssoEnabled 或环境变量 TRILIUM_SSO_ENABLED 为 true 以启用(需要重启)",
|
||||
|
@ -1313,6 +1313,7 @@
|
||||
"multi_factor_authentication": {
|
||||
"title": "Multi-Factor Authentication",
|
||||
"description": "Multi-Factor Authentication (MFA) adds an extra layer of security to your account. Instead of just entering a password to log in, MFA requires you to provide one or more additional pieces of evidence to verify your identity. This way, even if someone gets hold of your password, they still can't access your account without the second piece of information. It's like adding an extra lock to your door, making it much harder for anyone else to break in.",
|
||||
"electron_disabled": "Multi-Factor Authentication is not supported in the desktop build currently.",
|
||||
"oauth_title": "OAuth/OpenID",
|
||||
"oauth_enabled": "OAuth/OpenID Enabled",
|
||||
"oauth_enable_description": "Set ssoEnabled in config file or TRILIUM_SSO_ENABLED environment variable to true to enable (Requires restart)",
|
||||
|
Loading…
x
Reference in New Issue
Block a user