feat: numeric one-time password (#11846)

Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
fufesou 2025-05-23 17:10:47 +08:00 committed by GitHub
parent 6ff679c6b4
commit 3c028fe5b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
51 changed files with 110 additions and 3 deletions

View File

@ -110,6 +110,8 @@ const String kOptionAllowRemoteConfigModification =
"allow-remote-config-modification";
const String kOptionVerificationMethod = "verification-method";
const String kOptionApproveMode = "approve-mode";
const String kOptionAllowNumericOneTimePassword =
"allow-numeric-one-time-password";
const String kOptionCollapseToolbar = "collapse_toolbar";
const String kOptionShowRemoteCursor = "show_remote_cursor";
const String kOptionFollowRemoteCursor = "follow_remote_cursor";

View File

@ -1097,6 +1097,34 @@ class _SafetyState extends State<_Safety> with AutomaticKeepAliveClientMixin {
))
.toList();
final isOptFixedNumOTP =
isOptionFixed(kOptionAllowNumericOneTimePassword);
final isNumOPTChangable = !isOptFixedNumOTP && tmpEnabled && !locked;
final numericOneTimePassword = GestureDetector(
child: InkWell(
child: Row(
children: [
Checkbox(
value: model.allowNumericOneTimePassword,
onChanged: isNumOPTChangable
? (bool? v) {
model.switchAllowNumericOneTimePassword();
}
: null)
.marginOnly(right: 5),
Expanded(
child: Text(
translate('Numeric one-time password'),
style: TextStyle(
color: disabledTextColor(context, isNumOPTChangable)),
))
],
)),
onTap: isNumOPTChangable
? () => model.switchAllowNumericOneTimePassword()
: null,
).marginOnly(left: _kContentHSubMargin - 5);
final modeKeys = <String>[
'password',
'click',
@ -1133,6 +1161,7 @@ class _SafetyState extends State<_Safety> with AutomaticKeepAliveClientMixin {
],
),
enabled: tmpEnabled && !locked),
numericOneTimePassword,
if (usePassword) radios[1],
if (usePassword)
_SubButton('Set permanent password', setPasswordDialog,

View File

@ -56,6 +56,10 @@ class _DropDownAction extends StatelessWidget {
final verificationMethod = gFFI.serverModel.verificationMethod;
final showPasswordOption = approveMode != 'click';
final isApproveModeFixed = isOptionFixed(kOptionApproveMode);
final isNumericOneTimePasswordFixed =
isOptionFixed(kOptionAllowNumericOneTimePassword);
final isAllowNumericOneTimePassword =
gFFI.serverModel.allowNumericOneTimePassword;
return [
PopupMenuItem(
enabled: gFFI.serverModel.connectStatus > 0,
@ -94,6 +98,14 @@ class _DropDownAction extends StatelessWidget {
value: "setTemporaryPasswordLength",
child: Text(translate("One-time password length")),
),
if (showPasswordOption &&
verificationMethod != kUsePermanentPassword)
PopupMenuItem(
value: "allowNumericOneTimePassword",
child: listTile(translate("Numeric one-time password"),
isAllowNumericOneTimePassword),
enabled: !isNumericOneTimePasswordFixed,
),
if (showPasswordOption) const PopupMenuDivider(),
if (showPasswordOption)
PopupMenuItem(
@ -124,6 +136,9 @@ class _DropDownAction extends StatelessWidget {
setPasswordDialog();
} else if (value == "setTemporaryPasswordLength") {
setTemporaryPasswordLengthDialog(gFFI.dialogManager);
} else if (value == "allowNumericOneTimePassword") {
gFFI.serverModel.switchAllowNumericOneTimePassword();
gFFI.serverModel.updatePasswordModel();
} else if (value == kUsePermanentPassword ||
value == kUseTemporaryPassword ||
value == kUseBothPasswords) {

View File

@ -36,6 +36,7 @@ class ServerModel with ChangeNotifier {
int _connectStatus = 0; // Rendezvous Server status
String _verificationMethod = "";
String _temporaryPasswordLength = "";
bool _allowNumericOneTimePassword = false;
String _approveMode = "";
int _zeroClientLengthCounter = 0;
@ -112,6 +113,12 @@ class ServerModel with ChangeNotifier {
*/
}
bool get allowNumericOneTimePassword => _allowNumericOneTimePassword;
switchAllowNumericOneTimePassword() async {
await mainSetBoolOption(
kOptionAllowNumericOneTimePassword, !_allowNumericOneTimePassword);
}
TextEditingController get serverId => _serverId;
TextEditingController get serverPasswd => _serverPasswd;
@ -227,6 +234,8 @@ class ServerModel with ChangeNotifier {
final temporaryPasswordLength =
await bind.mainGetOption(key: "temporary-password-length");
final approveMode = await bind.mainGetOption(key: kOptionApproveMode);
final numericOneTimePassword =
await mainGetBoolOption(kOptionAllowNumericOneTimePassword);
/*
var hideCm = option2bool(
'allow-hide-cm', await bind.mainGetOption(key: 'allow-hide-cm'));
@ -265,6 +274,10 @@ class ServerModel with ChangeNotifier {
_temporaryPasswordLength = temporaryPasswordLength;
update = true;
}
if (_allowNumericOneTimePassword != numericOneTimePassword) {
_allowNumericOneTimePassword = numericOneTimePassword;
update = true;
}
/*
if (_hideCm != hideCm) {
_hideCm = hideCm;
@ -817,8 +830,8 @@ class Client {
RxInt unreadChatMessageCount = 0.obs;
Client(this.id, this.authorized, this.isFileTransfer, this.isViewCamera, this.name, this.peerId,
this.keyboard, this.clipboard, this.audio);
Client(this.id, this.authorized, this.isFileTransfer, this.isViewCamera,
this.name, this.peerId, this.keyboard, this.clipboard, this.audio);
Client.fromJson(Map<String, dynamic> json) {
id = json['id'];

@ -1 +1 @@
Subproject commit 53709d8f8dd09a1491f4d8866e9643804caa380b
Subproject commit 15a71f07a5bd8f7951b6869bea06f85064e41c67

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", ""),
("Trackpad speed", ""),
("Default trackpad speed", ""),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", ""),
("Trackpad speed", ""),
("Default trackpad speed", ""),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", ""),
("Trackpad speed", ""),
("Default trackpad speed", ""),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", ""),
("Trackpad speed", ""),
("Default trackpad speed", ""),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", "使用 WebSocket"),
("Trackpad speed", "触控板速度"),
("Default trackpad speed", "默认触控板速度"),
("Numeric one-time password", "一次性密码为数字"),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", ""),
("Trackpad speed", ""),
("Default trackpad speed", ""),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", ""),
("Trackpad speed", ""),
("Default trackpad speed", ""),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", "WebSocket verwenden"),
("Trackpad speed", "Geschwindigkeit des Trackpads"),
("Default trackpad speed", "Standardgeschwindigkeit des Trackpads"),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", ""),
("Trackpad speed", ""),
("Default trackpad speed", ""),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", ""),
("Trackpad speed", ""),
("Default trackpad speed", ""),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", ""),
("Trackpad speed", ""),
("Default trackpad speed", ""),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", ""),
("Trackpad speed", ""),
("Default trackpad speed", ""),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", ""),
("Trackpad speed", ""),
("Default trackpad speed", ""),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -696,5 +696,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("update-failed-check-msi-tip", "بررسی روش نصب انجام نشد. لطفاً برای بارگیری از صفحه انتشار ، روی دکمه 'بارگیری' کلیک کنید و به صورت دستی ارتقا دهید."),
("websocket_tip", "فقط اتصالات رله پشتیبانی می شوند ، WebSocket هنگام استفاده از ."),
("Use WebSocket", "استفاده کنید WebSocket از"),
("Trackpad speed", ""),
("Default trackpad speed", ""),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", "Utiliser WebSocket"),
("Trackpad speed", "Vitesse du pavé tactile"),
("Default trackpad speed", "Vitesse par défaut du pavé tactile"),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", ""),
("Trackpad speed", ""),
("Default trackpad speed", ""),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", "השתמש ב־WebSocket"),
("Trackpad speed", "מהירות משטח מגע"),
("Default trackpad speed", "מהירות ברירת מחדל של משטח מגע"),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", ""),
("Trackpad speed", ""),
("Default trackpad speed", ""),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", "WebSocket használata"),
("Trackpad speed", "Érintőpad sebessége"),
("Default trackpad speed", "Alapértelmezett érintőpad sebessége"),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", ""),
("Trackpad speed", ""),
("Default trackpad speed", ""),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", "Usa WebSocket"),
("Trackpad speed", "Velocità trackpad"),
("Default trackpad speed", "Velocità predefinita trackpad"),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", ""),
("Trackpad speed", ""),
("Default trackpad speed", ""),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", "웹소켓 사용"),
("Trackpad speed", "트랙패드 속도"),
("Default trackpad speed", "기본 트랙패드 속도"),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", ""),
("Trackpad speed", ""),
("Default trackpad speed", ""),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", ""),
("Trackpad speed", ""),
("Default trackpad speed", ""),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", "Lietot WebSocket"),
("Trackpad speed", "Skārienpaliktņa ātrums"),
("Default trackpad speed", "Noklusējuma skārienpaliktņa ātrums"),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", ""),
("Trackpad speed", ""),
("Default trackpad speed", ""),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", "Gebruik het WebSocketprotocol"),
("Trackpad speed", "Snelheid Trackpad"),
("Default trackpad speed", "Standaardsnelheid Trackpad"),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", ""),
("Trackpad speed", ""),
("Default trackpad speed", ""),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", ""),
("Trackpad speed", ""),
("Default trackpad speed", ""),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", ""),
("Trackpad speed", ""),
("Default trackpad speed", ""),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", ""),
("Trackpad speed", ""),
("Default trackpad speed", ""),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", "Использовать WebSocket"),
("Trackpad speed", "Скорость трекпада"),
("Default trackpad speed", "Скорость трекпада по умолчанию"),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", ""),
("Trackpad speed", ""),
("Default trackpad speed", ""),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", ""),
("Trackpad speed", ""),
("Default trackpad speed", ""),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", ""),
("Trackpad speed", ""),
("Default trackpad speed", ""),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", ""),
("Trackpad speed", ""),
("Default trackpad speed", ""),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", ""),
("Trackpad speed", ""),
("Default trackpad speed", ""),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", ""),
("Trackpad speed", ""),
("Default trackpad speed", ""),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", ""),
("Trackpad speed", ""),
("Default trackpad speed", ""),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", ""),
("Trackpad speed", ""),
("Default trackpad speed", ""),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", ""),
("Trackpad speed", ""),
("Default trackpad speed", ""),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", ""),
("Trackpad speed", ""),
("Default trackpad speed", ""),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", "使用 WebSocket"),
("Trackpad speed", "觸控板速度"),
("Default trackpad speed", "預設觸控板速度"),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", ""),
("Trackpad speed", ""),
("Default trackpad speed", ""),
("Numeric one-time password", ""),
].iter().cloned().collect();
}

View File

@ -698,5 +698,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Use WebSocket", ""),
("Trackpad speed", ""),
("Default trackpad speed", ""),
("Numeric one-time password", ""),
].iter().cloned().collect();
}