mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-12-13 11:35:56 +00:00
android refactor password
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
@@ -20,9 +21,10 @@ void showError({Duration duration = SEC1}) {
|
||||
showToast(translate("Error"), duration: SEC1);
|
||||
}
|
||||
|
||||
void updatePasswordDialog() {
|
||||
final p0 = TextEditingController();
|
||||
final p1 = TextEditingController();
|
||||
void setPermanentPasswordDialog() {
|
||||
final pw = FFI.getByName("permanent_password");
|
||||
final p0 = TextEditingController(text: pw);
|
||||
final p1 = TextEditingController(text: pw);
|
||||
var validateLength = false;
|
||||
var validateSame = false;
|
||||
DialogManager.show((setState, close) {
|
||||
@@ -86,7 +88,7 @@ void updatePasswordDialog() {
|
||||
? () async {
|
||||
close();
|
||||
showLoading(translate("Waiting"));
|
||||
if (await FFI.serverModel.updatePassword(p0.text)) {
|
||||
if (await FFI.serverModel.setPermanentPassword(p0.text)) {
|
||||
showSuccess();
|
||||
} else {
|
||||
showError();
|
||||
@@ -100,6 +102,37 @@ void updatePasswordDialog() {
|
||||
});
|
||||
}
|
||||
|
||||
void setTemporaryPasswordLengthDialog() {
|
||||
List<String> lengths = ['6', '8', '10'];
|
||||
String length = FFI.getByName('option', 'temporary-password-length');
|
||||
var index = lengths.indexOf(length);
|
||||
if (index < 0) index = 0;
|
||||
length = lengths[index];
|
||||
DialogManager.show((setState, close) {
|
||||
final setLength = (newValue) {
|
||||
final oldValue = length;
|
||||
if (oldValue == newValue) return;
|
||||
setState(() {
|
||||
length = newValue;
|
||||
});
|
||||
Map<String, String> msg = Map()
|
||||
..["name"] = "temporary-password-length"
|
||||
..["value"] = newValue;
|
||||
FFI.setByName("option", jsonEncode(msg));
|
||||
FFI.setByName("temporary_password");
|
||||
};
|
||||
return CustomAlertDialog(
|
||||
title: Text(translate("Set temporary password length")),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children:
|
||||
lengths.map((e) => getRadio(e, e, length, setLength)).toList()),
|
||||
actions: [],
|
||||
contentPadding: 14,
|
||||
);
|
||||
}, backDismiss: true, clickMaskDismiss: true);
|
||||
}
|
||||
|
||||
void enterPasswordDialog(String id) {
|
||||
final controller = TextEditingController();
|
||||
var remember = FFI.getByName('remember', id) == 'true';
|
||||
|
||||
Reference in New Issue
Block a user