mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-02-17 22:11:30 +08:00
feat: numeric one-time password (#11846)
Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
@@ -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";
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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'];
|
||||
|
||||
Reference in New Issue
Block a user