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,27 +175,29 @@ class SourcePage extends HookConsumerWidget {
), ),
body: Form( body: Form(
key: form, key: form,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: ListView( child: ListView(
children: [ children: [
const SizedBox(height: 96 - kToolbarHeight), const SizedBox(height: 96 - kToolbarHeight),
Text( Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text(
source == null source == null
? l.settingsServersActionsAdd ? l.settingsServersActionsAdd
: l.settingsServersActionsEdit, : l.settingsServersActionsEdit,
style: theme.textTheme.displaySmall, style: theme.textTheme.displaySmall,
), ),
),
name, name,
address, address,
username, username,
password, password,
const SizedBox(height: 24),
forcePlaintextSwitch,
const FabPadding(), const FabPadding(),
], ],
), ),
), ),
), ),
),
); );
} }
} }
@ -224,14 +238,13 @@ 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(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
const SizedBox(height: 24), const SizedBox(height: 24),
Text( Text(label, style: theme.textTheme.titleMedium),
label,
style: theme.textTheme.titleMedium,
),
TextFormField( TextFormField(
controller: _controller, controller: _controller,
obscureText: obscureText, obscureText: obscureText,
@ -253,6 +266,7 @@ class LabeledTextField extends HookConsumerWidget {
}, },
), ),
], ],
),
); );
} }
} }

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;
} }