add plaintext password option

fixes #161
This commit is contained in:
austinried 2023-05-06 17:56:03 +09:00
parent 7b1da24748
commit 979a4b7c73
3 changed files with 54 additions and 106 deletions

View File

@ -146,13 +146,8 @@
], ],
"de": [ "de": [
"actionsCancel",
"actionsDelete",
"actionsDownload",
"actionsDownloadCancel",
"actionsDownloadDelete", "actionsDownloadDelete",
"actionsOk", "actionsOk",
"controlsShuffle",
"resourcesAlbumCount", "resourcesAlbumCount",
"resourcesArtistCount", "resourcesArtistCount",
"resourcesFilterAlbum", "resourcesFilterAlbum",
@ -177,13 +172,6 @@
], ],
"es": [ "es": [
"actionsCancel",
"actionsDelete",
"actionsDownload",
"actionsDownloadCancel",
"actionsDownloadDelete",
"actionsOk",
"controlsShuffle",
"resourcesAlbumCount", "resourcesAlbumCount",
"resourcesArtistCount", "resourcesArtistCount",
"resourcesFilterAlbum", "resourcesFilterAlbum",
@ -238,37 +226,6 @@
"settingsServersFieldsName" "settingsServersFieldsName"
], ],
"gl": [
"actionsCancel",
"actionsDelete",
"actionsDownload",
"actionsDownloadCancel",
"actionsDownloadDelete",
"actionsOk",
"controlsShuffle",
"resourcesAlbumCount",
"resourcesArtistCount",
"resourcesFilterAlbum",
"resourcesFilterArtist",
"resourcesFilterOwner",
"resourcesFilterYear",
"resourcesPlaylistCount",
"resourcesSongCount",
"resourcesSongListDeleteAllContent",
"resourcesSongListDeleteAllTitle",
"resourcesSortByAlbum",
"resourcesSortByAlbumCount",
"resourcesSortByTitle",
"resourcesSortByUpdated",
"settingsAboutActionsSupport",
"settingsNetworkOptionsOfflineMode",
"settingsNetworkOptionsOfflineModeOff",
"settingsNetworkOptionsOfflineModeOn",
"settingsNetworkOptionsStreamFormat",
"settingsNetworkOptionsStreamFormatServerDefault",
"settingsServersFieldsName"
],
"it": [ "it": [
"actionsCancel", "actionsCancel",
"actionsDelete", "actionsDelete",
@ -594,28 +551,11 @@
], ],
"zh": [ "zh": [
"actionsCancel",
"actionsDelete",
"actionsDownload",
"actionsDownloadCancel",
"actionsDownloadDelete",
"actionsOk",
"controlsShuffle", "controlsShuffle",
"resourcesAlbumCount", "resourcesAlbumCount",
"resourcesArtistCount", "resourcesArtistCount",
"resourcesFilterAlbum",
"resourcesFilterArtist",
"resourcesFilterOwner",
"resourcesFilterYear",
"resourcesPlaylistCount", "resourcesPlaylistCount",
"resourcesSongCount", "resourcesSongCount",
"resourcesSongListDeleteAllContent",
"resourcesSongListDeleteAllTitle",
"resourcesSortByAlbum",
"resourcesSortByAlbumCount",
"resourcesSortByTitle",
"resourcesSortByUpdated",
"settingsAboutActionsSupport",
"settingsNetworkOptionsOfflineMode", "settingsNetworkOptionsOfflineMode",
"settingsNetworkOptionsOfflineModeOff", "settingsNetworkOptionsOfflineModeOff",
"settingsNetworkOptionsOfflineModeOn", "settingsNetworkOptionsOfflineModeOn",

View File

@ -61,6 +61,16 @@ class SourcePage extends HookConsumerWidget {
required: true, required: true,
); );
final forcePlaintextPassword = useState(!(source?.useTokenAuth ?? false));
final forcePlaintextSwitch = SwitchListTile(
value: forcePlaintextPassword.value,
title: Text(l.settingsServersOptionsForcePlaintextPasswordTitle),
subtitle: forcePlaintextPassword.value
? Text(l.settingsServersOptionsForcePlaintextPasswordDescriptionOn)
: Text(l.settingsServersOptionsForcePlaintextPasswordDescriptionOff),
onChanged: (value) => forcePlaintextPassword.value = value,
);
return WillPopScope( return WillPopScope(
onWillPop: () async => !isSaving.value && !isDeleting.value, onWillPop: () async => !isSaving.value && !isDeleting.value,
child: Scaffold( child: Scaffold(
@ -128,6 +138,7 @@ class SourcePage extends HookConsumerWidget {
address: Uri.parse(address.value), address: Uri.parse(address.value),
username: username.value, username: username.value,
password: password.value, password: password.value,
useTokenAuth: !forcePlaintextPassword.value,
), ),
); );
} else { } else {
@ -142,7 +153,8 @@ class SourcePage extends HookConsumerWidget {
features: IList(), features: IList(),
username: username.value, username: username.value,
password: password.value, password: password.value,
useTokenAuth: const Value(true), useTokenAuth:
Value(!forcePlaintextPassword.value),
), ),
); );
} }
@ -163,24 +175,26 @@ class SourcePage extends HookConsumerWidget {
), ),
body: Form( body: Form(
key: form, key: form,
child: Padding( child: ListView(
padding: const EdgeInsets.symmetric(horizontal: 24), children: [
child: ListView( const SizedBox(height: 96 - kToolbarHeight),
children: [ Padding(
const SizedBox(height: 96 - kToolbarHeight), padding: const EdgeInsets.symmetric(horizontal: 16),
Text( child: Text(
source == null source == null
? l.settingsServersActionsAdd ? l.settingsServersActionsAdd
: l.settingsServersActionsEdit, : l.settingsServersActionsEdit,
style: theme.textTheme.displaySmall, style: theme.textTheme.displaySmall,
), ),
name, ),
address, name,
username, address,
password, username,
const FabPadding(), password,
], const SizedBox(height: 24),
), forcePlaintextSwitch,
const FabPadding(),
],
), ),
), ),
), ),
@ -224,35 +238,35 @@ class LabeledTextField extends HookConsumerWidget {
final theme = Theme.of(context); final theme = Theme.of(context);
_controller = useTextEditingController(text: initialValue); _controller = useTextEditingController(text: initialValue);
return Column( return Padding(
crossAxisAlignment: CrossAxisAlignment.stretch, padding: const EdgeInsets.symmetric(horizontal: 16),
children: [ child: Column(
const SizedBox(height: 24), crossAxisAlignment: CrossAxisAlignment.stretch,
Text( children: [
label, const SizedBox(height: 24),
style: theme.textTheme.titleMedium, Text(label, style: theme.textTheme.titleMedium),
), TextFormField(
TextFormField( controller: _controller,
controller: _controller, obscureText: obscureText,
obscureText: obscureText, keyboardType: keyboardType,
keyboardType: keyboardType, validator: (value) {
validator: (value) { String? error;
String? error;
if (required) { if (required) {
error = _requiredValidator(value); error = _requiredValidator(value);
if (error != null) { if (error != null) {
return error; return error;
}
} }
}
if (validator != null) { if (validator != null) {
return validator!(value, label); return validator!(value, label);
} }
return null; return null;
}, },
), ),
], ],
),
); );
} }
} }

View File

@ -82,10 +82,4 @@ class MusicSource implements BaseMusicSource {
@override @override
Uri streamUri(String songId) => _source.streamUri(songId); Uri streamUri(String songId) => _source.streamUri(songId);
@override
bool operator ==(other) => other is BaseMusicSource && (other.id == id);
@override
int get hashCode => id;
} }