mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
feat: keyboard-interactive auth (#349)
This commit is contained in:
@@ -61,13 +61,16 @@ extension DialogX on BuildContext {
|
||||
|
||||
static final _recoredPwd = <String, String>{};
|
||||
|
||||
/// Show a dialog to input password
|
||||
///
|
||||
/// [hostId] set it to null to skip remembering the password
|
||||
Future<String?> showPwdDialog({
|
||||
String? user,
|
||||
required String hostId,
|
||||
String? hostId,
|
||||
String? title,
|
||||
}) async {
|
||||
if (!mounted) return null;
|
||||
return await showRoundDialog<String>(
|
||||
title: Text(user ?? l10n.pwd),
|
||||
title: Text(title ?? hostId ?? l10n.pwd),
|
||||
child: Input(
|
||||
controller: TextEditingController(text: _recoredPwd[hostId]),
|
||||
autoFocus: true,
|
||||
@@ -75,7 +78,7 @@ extension DialogX on BuildContext {
|
||||
obscureText: true,
|
||||
onSubmitted: (val) {
|
||||
pop(val);
|
||||
if (Stores.setting.rememberPwdInMem.fetch()) {
|
||||
if (hostId != null && Stores.setting.rememberPwdInMem.fetch()) {
|
||||
_recoredPwd[hostId] = val;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -81,9 +81,9 @@ extension SSHClientX on SSHClient {
|
||||
isRequestingPwd = true;
|
||||
final user = Miscs.pwdRequestWithUserReg.firstMatch(data)?.group(1);
|
||||
if (context == null) return;
|
||||
final pwd = await context.showPwdDialog(user: user, hostId: id);
|
||||
final pwd = await context.showPwdDialog(title: user, hostId: id);
|
||||
if (pwd == null || pwd.isEmpty) {
|
||||
session.kill(SSHSignal.INT);
|
||||
session.kill(SSHSignal.TERM);
|
||||
} else {
|
||||
session.stdin.add('$pwd\n'.uint8List);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user