Browse Source

neon: Required setting scheme for login

pull/273/head
jld3103 2 years ago
parent
commit
a74238d3bc
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 12
      packages/neon/neon/lib/src/pages/login.dart
  2. 5
      packages/neon/neon/lib/src/utils/validators.dart

12
packages/neon/neon/lib/src/pages/login.dart

@ -200,18 +200,10 @@ class _LoginPageState extends State<LoginPage> {
),
keyboardType: TextInputType.url,
initialValue: widget.serverURL,
validator: (final input) => validateHttpUrl(
context,
input,
allowEmptyScheme: true,
),
validator: (final input) => validateHttpUrl(context, input),
onFieldSubmitted: (final input) {
if (_formKey.currentState!.validate()) {
var url = input;
if (!(url.startsWith('http://') || url.startsWith('https://'))) {
url = 'http://$url';
}
_loginBloc.setServerURL(url);
_loginBloc.setServerURL(input);
} else {
_focusNode.requestFocus();
}

5
packages/neon/neon/lib/src/utils/validators.dart

@ -4,7 +4,6 @@ String? validateHttpUrl(
final BuildContext context,
final String? input, {
final bool httpsOnly = false,
final bool allowEmptyScheme = false,
}) {
if (input == null || input == '') {
return AppLocalizations.of(context).errorInvalidURL;
@ -15,9 +14,7 @@ String? validateHttpUrl(
return null;
}
if (uri.isScheme('http') && !httpsOnly) {
return null;
}
if (uri.isScheme('') && allowEmptyScheme) {
// TODO: Maybe make a better error message for http URLs if only https is allowed
return null;
}
} catch (_) {}

Loading…
Cancel
Save