Skip to content

Commit

Permalink
add plaintext password option
Browse files Browse the repository at this point in the history
fixes #161
  • Loading branch information
austinried committed May 6, 2023
1 parent 7b1da24 commit 979a4b7
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 106 deletions.
60 changes: 0 additions & 60 deletions .untranslated-messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,8 @@
],

"de": [
"actionsCancel",
"actionsDelete",
"actionsDownload",
"actionsDownloadCancel",
"actionsDownloadDelete",
"actionsOk",
"controlsShuffle",
"resourcesAlbumCount",
"resourcesArtistCount",
"resourcesFilterAlbum",
Expand All @@ -177,13 +172,6 @@
],

"es": [
"actionsCancel",
"actionsDelete",
"actionsDownload",
"actionsDownloadCancel",
"actionsDownloadDelete",
"actionsOk",
"controlsShuffle",
"resourcesAlbumCount",
"resourcesArtistCount",
"resourcesFilterAlbum",
Expand Down Expand Up @@ -238,37 +226,6 @@
"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": [
"actionsCancel",
"actionsDelete",
Expand Down Expand Up @@ -594,28 +551,11 @@
],

"zh": [
"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",
Expand Down
94 changes: 54 additions & 40 deletions lib/app/pages/source_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ class SourcePage extends HookConsumerWidget {
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(
onWillPop: () async => !isSaving.value && !isDeleting.value,
child: Scaffold(
Expand Down Expand Up @@ -128,6 +138,7 @@ class SourcePage extends HookConsumerWidget {
address: Uri.parse(address.value),
username: username.value,
password: password.value,
useTokenAuth: !forcePlaintextPassword.value,
),
);
} else {
Expand All @@ -142,7 +153,8 @@ class SourcePage extends HookConsumerWidget {
features: IList(),
username: username.value,
password: password.value,
useTokenAuth: const Value(true),
useTokenAuth:
Value(!forcePlaintextPassword.value),
),
);
}
Expand All @@ -163,24 +175,26 @@ class SourcePage extends HookConsumerWidget {
),
body: Form(
key: form,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: ListView(
children: [
const SizedBox(height: 96 - kToolbarHeight),
Text(
child: ListView(
children: [
const SizedBox(height: 96 - kToolbarHeight),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text(
source == null
? l.settingsServersActionsAdd
: l.settingsServersActionsEdit,
style: theme.textTheme.displaySmall,
),
name,
address,
username,
password,
const FabPadding(),
],
),
),
name,
address,
username,
password,
const SizedBox(height: 24),
forcePlaintextSwitch,
const FabPadding(),
],
),
),
),
Expand Down Expand Up @@ -224,35 +238,35 @@ class LabeledTextField extends HookConsumerWidget {
final theme = Theme.of(context);
_controller = useTextEditingController(text: initialValue);

return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const SizedBox(height: 24),
Text(
label,
style: theme.textTheme.titleMedium,
),
TextFormField(
controller: _controller,
obscureText: obscureText,
keyboardType: keyboardType,
validator: (value) {
String? error;
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const SizedBox(height: 24),
Text(label, style: theme.textTheme.titleMedium),
TextFormField(
controller: _controller,
obscureText: obscureText,
keyboardType: keyboardType,
validator: (value) {
String? error;

if (required) {
error = _requiredValidator(value);
if (error != null) {
return error;
if (required) {
error = _requiredValidator(value);
if (error != null) {
return error;
}
}
}

if (validator != null) {
return validator!(value, label);
}
return null;
},
),
],
if (validator != null) {
return validator!(value, label);
}
return null;
},
),
],
),
);
}
}
6 changes: 0 additions & 6 deletions lib/sources/music_source.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,4 @@ class MusicSource implements BaseMusicSource {

@override
Uri streamUri(String songId) => _source.streamUri(songId);

@override
bool operator ==(other) => other is BaseMusicSource && (other.id == id);

@override
int get hashCode => id;
}

0 comments on commit 979a4b7

Please sign in to comment.