mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
remove special treatment when only use permanent passwrod but no password set (#8566)
1. Remove special treatment when only use permanent passwrod but no password set, it has no need and `Connection not allowd` prompt make user confusing. 2. When only use permanent password is chosen and the permanent password is empty, pop up the set-password dialog, if still not set in the dialog, back to the old choice 3. Add cancel confirm for 2fa and telegram bot Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
@@ -2188,3 +2188,31 @@ void setSharedAbPasswordDialog(String abName, Peer peer) {
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
void CommonConfirmDialog(OverlayDialogManager dialogManager, String content,
|
||||
VoidCallback onConfirm) {
|
||||
dialogManager.show((setState, close, context) {
|
||||
submit() {
|
||||
close();
|
||||
onConfirm.call();
|
||||
}
|
||||
|
||||
return CustomAlertDialog(
|
||||
content: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(content,
|
||||
style: const TextStyle(fontSize: 15),
|
||||
textAlign: TextAlign.start),
|
||||
),
|
||||
],
|
||||
).marginOnly(bottom: 12),
|
||||
actions: [
|
||||
dialogButton(translate("Cancel"), onPressed: close, isOutline: true),
|
||||
dialogButton(translate("OK"), onPressed: submit),
|
||||
],
|
||||
onSubmit: submit,
|
||||
onCancel: close,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -838,7 +838,7 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
}
|
||||
}
|
||||
|
||||
void setPasswordDialog() async {
|
||||
void setPasswordDialog({VoidCallback? notEmptyCallback}) async {
|
||||
final pw = await bind.mainGetPermanentPassword();
|
||||
final p0 = TextEditingController(text: pw);
|
||||
final p1 = TextEditingController(text: pw);
|
||||
@@ -878,6 +878,9 @@ void setPasswordDialog() async {
|
||||
return;
|
||||
}
|
||||
bind.mainSetPermanentPassword(password: pass);
|
||||
if (pass.isNotEmpty) {
|
||||
notEmptyCallback?.call();
|
||||
}
|
||||
close();
|
||||
}
|
||||
|
||||
|
||||
@@ -684,10 +684,18 @@ class _SafetyState extends State<_Safety> with AutomaticKeepAliveClientMixin {
|
||||
RxBool hasBot = bind.mainHasValidBotSync().obs;
|
||||
update() async {
|
||||
has2fa.value = bind.mainHasValid2FaSync();
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
onChanged(bool? checked) async {
|
||||
change2fa(callback: update);
|
||||
if (checked == false) {
|
||||
CommonConfirmDialog(
|
||||
gFFI.dialogManager, translate('cancel-2fa-confirm-tip'), () {
|
||||
change2fa(callback: update);
|
||||
});
|
||||
} else {
|
||||
change2fa(callback: update);
|
||||
}
|
||||
}
|
||||
|
||||
final tfa = GestureDetector(
|
||||
@@ -716,10 +724,18 @@ class _SafetyState extends State<_Safety> with AutomaticKeepAliveClientMixin {
|
||||
}
|
||||
updateBot() async {
|
||||
hasBot.value = bind.mainHasValidBotSync();
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
onChangedBot(bool? checked) async {
|
||||
changeBot(callback: updateBot);
|
||||
if (checked == false) {
|
||||
CommonConfirmDialog(
|
||||
gFFI.dialogManager, translate('cancel-bot-confirm-tip'), () {
|
||||
changeBot(callback: updateBot);
|
||||
});
|
||||
} else {
|
||||
changeBot(callback: updateBot);
|
||||
}
|
||||
}
|
||||
|
||||
final bot = GestureDetector(
|
||||
@@ -873,12 +889,22 @@ class _SafetyState extends State<_Safety> with AutomaticKeepAliveClientMixin {
|
||||
label: value,
|
||||
onChanged: locked
|
||||
? null
|
||||
: ((value) {
|
||||
() async {
|
||||
: ((value) async {
|
||||
callback() async {
|
||||
await model.setVerificationMethod(
|
||||
passwordKeys[passwordValues.indexOf(value)]);
|
||||
await model.updatePasswordModel();
|
||||
}();
|
||||
}
|
||||
|
||||
if (value ==
|
||||
passwordValues[passwordKeys
|
||||
.indexOf(kUsePermanentPassword)] &&
|
||||
(await bind.mainGetPermanentPassword())
|
||||
.isEmpty) {
|
||||
setPasswordDialog(notEmptyCallback: callback);
|
||||
} else {
|
||||
await callback();
|
||||
}
|
||||
}),
|
||||
))
|
||||
.toList();
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_hbb/desktop/pages/desktop_home_page.dart';
|
||||
import 'package:flutter_hbb/mobile/widgets/dialog.dart';
|
||||
import 'package:flutter_hbb/models/chat_model.dart';
|
||||
import 'package:get/get.dart';
|
||||
@@ -101,18 +102,27 @@ class ServerPage extends StatefulWidget implements PageShape {
|
||||
),
|
||||
];
|
||||
},
|
||||
onSelected: (value) {
|
||||
onSelected: (value) async {
|
||||
if (value == "changeID") {
|
||||
changeIdDialog();
|
||||
} else if (value == "setPermanentPassword") {
|
||||
setPermanentPasswordDialog(gFFI.dialogManager);
|
||||
setPasswordDialog();
|
||||
} else if (value == "setTemporaryPasswordLength") {
|
||||
setTemporaryPasswordLengthDialog(gFFI.dialogManager);
|
||||
} else if (value == kUsePermanentPassword ||
|
||||
value == kUseTemporaryPassword ||
|
||||
value == kUseBothPasswords) {
|
||||
bind.mainSetOption(key: kOptionVerificationMethod, value: value);
|
||||
gFFI.serverModel.updatePasswordModel();
|
||||
callback() {
|
||||
bind.mainSetOption(key: kOptionVerificationMethod, value: value);
|
||||
gFFI.serverModel.updatePasswordModel();
|
||||
}
|
||||
|
||||
if (value == kUsePermanentPassword &&
|
||||
(await bind.mainGetPermanentPassword()).isEmpty) {
|
||||
setPasswordDialog(notEmptyCallback: callback);
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
} else if (value.startsWith("AcceptSessionsVia")) {
|
||||
value = value.substring("AcceptSessionsVia".length);
|
||||
if (value == "Password") {
|
||||
|
||||
Reference in New Issue
Block a user