mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
new: remember pwd in mem
This commit is contained in:
@@ -4,6 +4,7 @@ import 'package:choice/choice.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:toolbox/core/extension/context/common.dart';
|
||||
import 'package:toolbox/core/extension/context/locale.dart';
|
||||
import 'package:toolbox/data/res/store.dart';
|
||||
import 'package:toolbox/view/widget/choice_chip.dart';
|
||||
import 'package:toolbox/view/widget/tag.dart';
|
||||
|
||||
@@ -57,17 +58,27 @@ extension DialogX on BuildContext {
|
||||
}
|
||||
}
|
||||
|
||||
Future<String?> showPwdDialog(
|
||||
static final _recoredPwd = <String, String>{};
|
||||
|
||||
Future<String?> showPwdDialog({
|
||||
String? user,
|
||||
) async {
|
||||
required String hostId,
|
||||
void Function()? onCorrectPwd,
|
||||
}) async {
|
||||
if (!mounted) return null;
|
||||
return await showRoundDialog<String>(
|
||||
title: Text(user ?? l10n.pwd),
|
||||
child: Input(
|
||||
controller: TextEditingController(text: _recoredPwd[hostId]),
|
||||
autoFocus: true,
|
||||
type: TextInputType.visiblePassword,
|
||||
obscureText: true,
|
||||
onSubmitted: (val) => pop(val.trim()),
|
||||
onSubmitted: (val) {
|
||||
pop(val);
|
||||
if (Stores.setting.rememberPwdInMem.fetch()) {
|
||||
_recoredPwd[hostId] = val;
|
||||
}
|
||||
},
|
||||
label: l10n.pwd,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -67,6 +67,7 @@ extension SSHClientX on SSHClient {
|
||||
_OnStdout? onStderr,
|
||||
_OnStdin? stdin,
|
||||
bool redirectToBash = false, // not working yet. do not use
|
||||
required String id,
|
||||
}) async {
|
||||
var isRequestingPwd = false;
|
||||
final session = await exec(
|
||||
@@ -80,7 +81,7 @@ extension SSHClientX on SSHClient {
|
||||
isRequestingPwd = true;
|
||||
final user = Miscs.pwdRequestWithUserReg.firstMatch(data)?.group(1);
|
||||
if (context == null) return;
|
||||
final pwd = await context.showPwdDialog(user);
|
||||
final pwd = await context.showPwdDialog(user: user, hostId: id);
|
||||
if (pwd == null || pwd.isEmpty) {
|
||||
session.kill(SSHSignal.INT);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user