This commit is contained in:
parent
164f8ffc7c
commit
6d2023ba1b
@ -26,6 +26,7 @@
|
|||||||
#include "rpc/common.hpp"
|
#include "rpc/common.hpp"
|
||||||
#include "types/repertory.hpp"
|
#include "types/repertory.hpp"
|
||||||
#include "ui/mgmt_app_config.hpp"
|
#include "ui/mgmt_app_config.hpp"
|
||||||
|
#include "utils/collection.hpp"
|
||||||
#include "utils/common.hpp"
|
#include "utils/common.hpp"
|
||||||
#include "utils/config.hpp"
|
#include "utils/config.hpp"
|
||||||
#include "utils/error_utils.hpp"
|
#include "utils/error_utils.hpp"
|
||||||
@ -42,7 +43,11 @@ namespace {
|
|||||||
return std::string{data};
|
return std::string{data};
|
||||||
}
|
}
|
||||||
|
|
||||||
auto decoded = macaron::Base64::Decode(data);
|
repertory::data_buffer decoded;
|
||||||
|
if (not repertory::utils::collection::from_hex_string(data, decoded)) {
|
||||||
|
throw repertory::utils::error::create_exception(function_name,
|
||||||
|
{"decryption failed"});
|
||||||
|
}
|
||||||
repertory::data_buffer buffer(decoded.size());
|
repertory::data_buffer buffer(decoded.size());
|
||||||
|
|
||||||
auto key = repertory::utils::encryption::create_hash_blake2b_256(password);
|
auto key = repertory::utils::encryption::create_hash_blake2b_256(password);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:convert/convert.dart';
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -270,6 +271,7 @@ Future<Map<String, dynamic>> convertAllToString(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
debugPrint('password|$password');
|
||||||
settings[entry.key] = encryptValue(entry.value, password!);
|
settings[entry.key] = encryptValue(entry.value, password!);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -312,7 +314,7 @@ String encryptValue(String value, String password) {
|
|||||||
nonce: nonce,
|
nonce: nonce,
|
||||||
);
|
);
|
||||||
|
|
||||||
return base64Encode(Uint8List.fromList([...nonce, ...data]));
|
return hex.encode(nonce + data);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String?> promptPassword() async {
|
Future<String?> promptPassword() async {
|
||||||
@ -320,7 +322,7 @@ Future<String?> promptPassword() async {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String updatedValue1 = '';
|
String password = '';
|
||||||
return await showDialog(
|
return await showDialog(
|
||||||
context: constants.navigatorKey.currentContext!,
|
context: constants.navigatorKey.currentContext!,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
@ -333,23 +335,54 @@ Future<String?> promptPassword() async {
|
|||||||
TextButton(
|
TextButton(
|
||||||
child: const Text('OK'),
|
child: const Text('OK'),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (updatedValue1.isEmpty) {
|
if (password.isEmpty) {
|
||||||
return displayErrorMessage(context, "Password is not valid");
|
return displayErrorMessage(context, "Password is not valid");
|
||||||
}
|
}
|
||||||
|
|
||||||
Navigator.of(context).pop(updatedValue1);
|
Navigator.of(context).pop(password);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
content: TextField(
|
content: TextField(
|
||||||
autofocus: true,
|
autofocus: true,
|
||||||
controller: TextEditingController(text: updatedValue1),
|
controller: TextEditingController(text: password),
|
||||||
obscureText: true,
|
obscureText: true,
|
||||||
obscuringCharacter: '*',
|
obscuringCharacter: '*',
|
||||||
onChanged: (value) => updatedValue1 = value,
|
onChanged: (value) => password = value,
|
||||||
),
|
),
|
||||||
title: const Text('Enter Authentication Password'),
|
title: const Text('Enter Authentication Password'),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> getChanged(
|
||||||
|
Map<String, dynamic> original,
|
||||||
|
Map<String, dynamic> updated,
|
||||||
|
) {
|
||||||
|
if (DeepCollectionEquality().equals(original, updated)) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> changedSettings = {};
|
||||||
|
original.forEach((key, value) {
|
||||||
|
if (DeepCollectionEquality().equals(value, updated[key])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value is Map<String, dynamic>) {
|
||||||
|
changedSettings[key] = <String, dynamic>{};
|
||||||
|
value.forEach((subKey, subValue) {
|
||||||
|
if (DeepCollectionEquality().equals(subValue, updated[key][subKey])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
changedSettings[key][subKey] = updated[key][subKey];
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
changedSettings[key] = updated[key];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return changedSettings;
|
||||||
|
}
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
import 'package:collection/collection.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:repertory/constants.dart' as constants;
|
import 'package:repertory/constants.dart' as constants;
|
||||||
import 'package:repertory/helpers.dart'
|
import 'package:repertory/helpers.dart'
|
||||||
show convertAllToString, getSettingDescription, getSettingValidators;
|
show
|
||||||
|
convertAllToString,
|
||||||
|
getChanged,
|
||||||
|
getSettingDescription,
|
||||||
|
getSettingValidators;
|
||||||
import 'package:repertory/models/mount.dart';
|
import 'package:repertory/models/mount.dart';
|
||||||
import 'package:repertory/models/mount_list.dart';
|
import 'package:repertory/models/mount_list.dart';
|
||||||
import 'package:repertory/settings.dart';
|
import 'package:repertory/settings.dart';
|
||||||
@ -614,30 +617,12 @@ class _MountSettingsWidgetState extends State<MountSettingsWidget> {
|
|||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
if (!widget.isAdd) {
|
if (!widget.isAdd) {
|
||||||
var settings = widget.mount.mountConfig.settings;
|
final settings = getChanged(
|
||||||
Map<String, dynamic> changedSettings = {};
|
widget.mount.mountConfig.settings,
|
||||||
if (!DeepCollectionEquality().equals(widget.settings, settings)) {
|
widget.settings,
|
||||||
widget.settings.forEach((key, value) {
|
);
|
||||||
if (!DeepCollectionEquality().equals(settings[key], value)) {
|
if (settings.isNotEmpty) {
|
||||||
if (value is Map<String, dynamic>) {
|
convertAllToString(settings).then((map) {
|
||||||
changedSettings[key] = <String, dynamic>{};
|
|
||||||
value.forEach((subKey, subValue) {
|
|
||||||
if (!DeepCollectionEquality().equals(
|
|
||||||
settings[key][subKey],
|
|
||||||
subValue,
|
|
||||||
)) {
|
|
||||||
changedSettings[key][subKey] = subValue;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
changedSettings[key] = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (changedSettings.isNotEmpty) {
|
|
||||||
convertAllToString(changedSettings).then((map) {
|
|
||||||
map.forEach((key, value) {
|
map.forEach((key, value) {
|
||||||
if (value is Map<String, dynamic>) {
|
if (value is Map<String, dynamic>) {
|
||||||
value.forEach((subKey, subValue) {
|
value.forEach((subKey, subValue) {
|
||||||
|
@ -39,6 +39,7 @@ dependencies:
|
|||||||
provider: ^6.1.2
|
provider: ^6.1.2
|
||||||
settings_ui: ^2.0.2
|
settings_ui: ^2.0.2
|
||||||
sodium_libs: ^3.4.4+1
|
sodium_libs: ^3.4.4+1
|
||||||
|
convert: ^3.1.2
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user