Resolves #549 trim spaces for device name, url and long-lived token
This commit is contained in:
parent
12ba5598e4
commit
8221eceb78
@ -44,7 +44,6 @@ class _ConnectionSettingsPageState extends State<ConnectionSettingsPage> {
|
||||
}
|
||||
|
||||
_saveSettings() async {
|
||||
_homeAssistantUrl = _homeAssistantUrl.trim();
|
||||
String socketProtocol;
|
||||
String domain;
|
||||
String port;
|
||||
@ -96,10 +95,10 @@ class _ConnectionSettingsPageState extends State<ConnectionSettingsPage> {
|
||||
)
|
||||
),
|
||||
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<ConnectionSettingsPage> {
|
||||
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<ConnectionSettingsPage> {
|
||||
)
|
||||
),
|
||||
validator: (value) {
|
||||
if (value.isEmpty) {
|
||||
if (value.trim().isEmpty) {
|
||||
return 'Device name is required';
|
||||
}
|
||||
return null;
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user