Skip to content

Commit da75a56

Browse files
committed
Login options testing
1 parent 2326c85 commit da75a56

6 files changed

Lines changed: 27 additions & 7 deletions

File tree

l10n/app_en.arb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,11 @@
7979
"login_connectionChanged": "Connection Changed!",
8080
"loginHTTP_title": "HTTP Credentials",
8181
"loginHTTP_message": "Basic access authentification is required by the Piwigo server:",
82+
"loginHTTP_enable": "Enable HTTP Basic",
8283
"loginHTTPuser_placeholder": "Username",
8384
"loginHTTPpwd_placeholder": "Password",
85+
"loginCert_title": "Self Signed Certificates",
86+
"loginCert_enable": "Allow SSL",
8487
"loginCertFailed_title": "Connection Not Private",
8588
"loginCertFailed_message": "Piwigo warns you when a website has a certificate that is not valid. Do you still want to accept this certificate?",
8689
"loginHTTPSfailed_title": "Secure Connection Failed",

l10n/app_fr.arb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,11 @@
5050
"login_connectionChanged": "Connexion Modifiée !",
5151
"loginHTTP_title": "Identification HTTP",
5252
"loginHTTP_message": "L'authentification HTTP est requise par le serveur Piwigo:",
53+
"loginHTTP_enable": "Activer HTTP Basic",
5354
"loginHTTPuser_placeholder": "Identifiant",
5455
"loginHTTPpwd_placeholder": "Mot de Passe",
56+
"loginCert_title": "Certificats auto-signés",
57+
"loginCert_enable": "Authoriser les SSL",
5558
"loginCertFailed_title": "Connexion Non Privée",
5659
"loginCertFailed_message": "Piwigo vous avertit lorsqu'un site web a un certificat non valide. Voulez-vous toujours accepter ce certificat ?",
5760
"loginHTTPSfailed_title": "Échec de la Connexion Sécurisée",

lib/api/api_interceptor.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'dart:convert';
2+
import 'dart:io';
23

34
import 'package:dio/dio.dart';
45
import 'package:flutter/material.dart';
@@ -44,6 +45,13 @@ class ApiInterceptor extends Interceptor {
4445
debugPrint(
4546
"[${err.response?.statusCode}] ${err.requestOptions.queryParameters['method']}");
4647
debugPrint('${err.error}\n${err.stackTrace}');
48+
if (err.error is HandshakeException) {
49+
HandshakeException handshakeError = err.error as HandshakeException;
50+
String? message = handshakeError.osError?.message;
51+
if (message != null && message.contains('CERTIFICATE_VERIFY_FAILED')) {
52+
// Invalid SSL
53+
}
54+
}
4755
switch (err.response?.statusCode) {
4856
case null:
4957
App.scaffoldMessengerKey.currentState?.showSnackBar(

lib/components/fields/settings_field.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ class SettingsField extends StatelessWidget {
1010
this.keyboardType,
1111
this.padding,
1212
this.focusNode,
13+
this.isObscure = false,
1314
}) : super(key: key);
1415

1516
final TextEditingController? controller;
1617
final FocusNode? focusNode;
1718
final TextInputType? keyboardType;
1819
final String? hint;
20+
final bool isObscure;
1921
final EdgeInsets? padding;
2022
final Function(String)? onChanged;
2123
final Function(String)? onFieldSubmitted;
@@ -32,6 +34,7 @@ class SettingsField extends StatelessWidget {
3234
onChanged: onChanged,
3335
onFieldSubmitted: onFieldSubmitted,
3436
style: Theme.of(context).textTheme.bodyMedium,
37+
obscureText: isObscure,
3538
decoration: InputDecoration(
3639
border: InputBorder.none,
3740
hintText: hint,

lib/components/sections/settings_section.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,11 +404,13 @@ class SettingsSectionItemField extends StatefulWidget {
404404
required this.onChanged,
405405
this.hint,
406406
required this.value,
407+
this.isObscure = false,
407408
}) : super(key: key);
408409

409410
final String? title;
410411
final String? hint;
411412
final String value;
413+
final bool isObscure;
412414
final Function(String) onChanged;
413415

414416
@override
@@ -428,11 +430,11 @@ class _SettingsSectionItemFieldState extends State<SettingsSectionItemField> {
428430
@override
429431
Widget build(BuildContext context) {
430432
return SettingsSectionItem(
431-
// title: widget.title,
432433
expandedChild: true,
433434
child: SettingsField(
434435
controller: _controller,
435436
hint: widget.hint,
437+
isObscure: widget.isObscure,
436438
onChanged: widget.onChanged,
437439
),
438440
);

lib/views/authentication/login_settings_page.dart

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ class _LoginSettingsPageState extends State<LoginSettingsPage> {
4646
),
4747
children: [
4848
SettingsSection(
49-
title: 'Invalid Certificates', // todo : translate
49+
title: appStrings.loginCert_title,
5050
children: [
5151
SettingsSectionItemSwitch(
52-
title: 'Enable SSL', // todo : translate
52+
title: appStrings.loginCert_enable,
5353
value: _sslEnabled,
5454
onChanged: (value) => setState(() {
5555
_sslEnabled = value;
@@ -62,10 +62,10 @@ class _LoginSettingsPageState extends State<LoginSettingsPage> {
6262
],
6363
),
6464
SettingsSection(
65-
title: 'HTTP Authorization', // todo : translate
65+
title: appStrings.loginHTTP_title,
6666
children: [
6767
SettingsSectionItemSwitch(
68-
title: 'Enable Basic Auth', // todo : translate
68+
title: appStrings.loginHTTP_enable,
6969
value: _basiAuth,
7070
onChanged: (value) => setState(() {
7171
_basiAuth = value;
@@ -83,7 +83,7 @@ class _LoginSettingsPageState extends State<LoginSettingsPage> {
8383
return Column(
8484
children: [
8585
SettingsSectionItemField(
86-
hint: 'Username', // todo : translate
86+
hint: appStrings.loginHTTPuser_placeholder,
8787
value: _basicAuthUsername,
8888
onChanged: (value) => setState(() {
8989
_basicAuthUsername = value;
@@ -98,8 +98,9 @@ class _LoginSettingsPageState extends State<LoginSettingsPage> {
9898
thickness: 1,
9999
),
100100
SettingsSectionItemField(
101-
hint: 'Password', // todo : translate
101+
hint: appStrings.loginHTTPpwd_placeholder,
102102
value: _basicAuthPassword,
103+
isObscure: true,
103104
onChanged: (value) => setState(() {
104105
_basicAuthPassword = value;
105106
appPreferences.setString(

0 commit comments

Comments
 (0)