add options: disable-change-permanent-password, disable-change-id, disable-unlock-pin (#13929)

Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
21pages
2026-01-07 13:51:02 +08:00
committed by GitHub
parent a05b619563
commit 9dd4fa8646
8 changed files with 59 additions and 20 deletions

View File

@@ -406,6 +406,10 @@ pub fn core_main() -> Option<Vec<String>> {
println!("Settings are disabled!");
return None;
}
if config::Config::is_disable_change_permanent_password() {
println!("Changing permanent password is disabled!");
return None;
}
if args.len() == 2 {
if crate::platform::is_installed() && is_root() {
if let Err(err) = crate::ipc::set_permanent_password(args[1].to_owned()) {
@@ -419,6 +423,10 @@ pub fn core_main() -> Option<Vec<String>> {
}
return None;
} else if args[0] == "--set-unlock-pin" {
if config::Config::is_disable_unlock_pin() {
println!("Unlock PIN is disabled!");
return None;
}
#[cfg(feature = "flutter")]
if args.len() == 2 {
if crate::platform::is_installed() && is_root() {
@@ -440,6 +448,10 @@ pub fn core_main() -> Option<Vec<String>> {
println!("Settings are disabled!");
return None;
}
if config::Config::is_disable_change_id() {
println!("Changing ID is disabled!");
return None;
}
if args.len() == 2 {
if crate::platform::is_installed() && is_root() {
let old_id = crate::ipc::get_id();

View File

@@ -16,6 +16,8 @@ const disable_ab = handler.is_disable_ab();
const hide_server_settings = handler.get_builtin_option("hide-server-settings") == "Y";
const hide_proxy_settings = handler.get_builtin_option("hide-proxy-settings") == "Y";
const hide_websocket_settings = handler.get_builtin_option("hide-websocket-settings") == "Y";
const disable_change_permanent_password = handler.get_builtin_option("disable-change-permanent-password") == "Y";
const disable_change_id = handler.get_builtin_option("disable-change-id") == "Y";
// html min-width, min-height not working on mac, below works for all
if (incoming_only) {
@@ -508,11 +510,11 @@ class MyIdMenu: Reactor.Component {
{!disable_settings && is_win && handler.is_installed() ? <ShareRdp /> : ""}
{!disable_settings && <DirectServer />}
{!disable_settings && false && handler.using_public_server() && <li #allow-always-relay><span>{svg_checkmark}</span>{translate('Always connect via relay')}</li>}
{handler.is_ok_change_id() ? <div .separator /> : ""}
{!disable_account && (username ?
{!disable_change_id && handler.is_ok_change_id() ? <div .separator /> : ""}
{!disable_account && (username ?
<li #logout>{translate('Logout')} ({username})</li> :
<li #login>{translate('Login')}</li>)}
{!disable_settings && handler.is_ok_change_id() && key_confirmed && connect_status > 0 ? <li #change-id>{translate('Change ID')}</li> : ""}
{!disable_change_id && !disable_settings && handler.is_ok_change_id() && key_confirmed && connect_status > 0 ? <li #change-id>{translate('Change ID')}</li> : ""}
<div .separator />
<li #allow-darktheme><span>{svg_checkmark}</span>{translate('Dark Theme')}</li>
<Languages />
@@ -1050,7 +1052,7 @@ class PasswordArea: Reactor.Component {
{ !show_password ? '' : <li #use-permanent-password><span>{svg_checkmark}</span>{translate('Use permanent password')}</li> }
{ !show_password ? '' : <li #use-both-passwords><span>{svg_checkmark}</span>{translate('Use both passwords')}</li> }
{ !show_password ? '' : <div .separator /> }
{ !show_password ? '' : <li #set-password disabled={ method == 'use-temporary-password' ? "true" : "false" }>{translate('Set permanent password')}</li> }
{ !show_password || disable_change_permanent_password ? '' : <li #set-password disabled={ method == 'use-temporary-password' ? "true" : "false" }>{translate('Set permanent password')}</li> }
{ !show_password ? '' : <TemporaryPasswordLengthMenu /> }
<div .separator />
<li #tfa><span>{svg_checkmark}</span>{translate('enable-2fa-title')}</li>