From 8221eceb78b04fee4d9b83fb7761d56d98c795f0 Mon Sep 17 00:00:00 2001 From: Yegor Vialov Date: Sun, 3 May 2020 13:47:11 +0000 Subject: [PATCH] Resolves #549 trim spaces for device name, url and long-lived token --- lib/pages/settings/connection_settings.part.dart | 9 ++++----- lib/popups.dart | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/pages/settings/connection_settings.part.dart b/lib/pages/settings/connection_settings.part.dart index 1a21b89..75101dc 100644 --- a/lib/pages/settings/connection_settings.part.dart +++ b/lib/pages/settings/connection_settings.part.dart @@ -44,7 +44,6 @@ class _ConnectionSettingsPageState extends State { } _saveSettings() async { - _homeAssistantUrl = _homeAssistantUrl.trim(); String socketProtocol; String domain; String port; @@ -96,10 +95,10 @@ class _ConnectionSettingsPageState extends State { ) ), onSaved: (newValue) { - _homeAssistantUrl = newValue; + _homeAssistantUrl = newValue.trim(); }, validator: (value) { - if (value.isEmpty) { + if (value.trim().isEmpty) { return 'Url is required'; } return null; @@ -138,7 +137,7 @@ class _ConnectionSettingsPageState extends State { TextFormField( initialValue: _deviceName, onSaved: (newValue) { - _deviceName = newValue; + _deviceName = newValue.trim(); }, decoration: InputDecoration( hintText: 'Please enter device name', @@ -148,7 +147,7 @@ class _ConnectionSettingsPageState extends State { ) ), validator: (value) { - if (value.isEmpty) { + if (value.trim().isEmpty) { return 'Device name is required'; } return null; diff --git a/lib/popups.dart b/lib/popups.dart index 0253fc6..ff46fcc 100644 --- a/lib/popups.dart +++ b/lib/popups.dart @@ -74,7 +74,7 @@ class TokenLoginPopup extends Popup { child: TextFormField( onSaved: (newValue) { final storage = new FlutterSecureStorage(); - storage.write(key: "hacl_llt", value: newValue).then((_) { + storage.write(key: "hacl_llt", value: newValue.trim()).then((_) { Navigator.of(context).pop(); eventBus.fire(SettingsChangedEvent(true)); }); @@ -87,7 +87,7 @@ class TokenLoginPopup extends Popup { ) ), validator: (value) { - if (value.isEmpty) { + if (value.trim().isEmpty) { return 'Long-lived token can\'t be emty'; } return null;