From 8678ec46606f14118bfd231ccf2f727c89af6109 Mon Sep 17 00:00:00 2001 From: Serhii Date: Tue, 31 Dec 2024 12:21:45 +0200 Subject: [PATCH] optionally include user data --- .../node_list/node_create_or_edit_view_model.dart | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/view_model/node_list/node_create_or_edit_view_model.dart b/lib/view_model/node_list/node_create_or_edit_view_model.dart index aa958072f..f6c036675 100644 --- a/lib/view_model/node_list/node_create_or_edit_view_model.dart +++ b/lib/view_model/node_list/node_create_or_edit_view_model.dart @@ -219,21 +219,25 @@ abstract class NodeCreateOrEditViewModelBase with Store { throw Exception('Unexpected scan QR code value: value is empty'); } - if (!code.contains('://')) { - code = 'tcp://$code'; - } + if (!code.contains('://')) code = 'tcp://$code'; final uri = Uri.tryParse(code); if (uri == null || uri.host.isEmpty) { throw Exception('Invalid QR code: Unable to parse or missing host.'); } + final userInfo = uri.userInfo; final ipAddress = uri.host; final port = uri.hasPort ? uri.port.toString() : ''; final path = uri.path; + final queryParams = uri.queryParameters; // Currently not used + final rpcUser = userInfo.split(':').first; + final rpcPassword = userInfo.split(':').length > 1 ? userInfo.split(':')[1] : ''; setAddress(ipAddress); setPath(path); + setPassword(rpcPassword); + setLogin(rpcUser); setPort(port); } on Exception catch (e) { connectionState = FailureState(e.toString());