Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Password Security #716

Merged
merged 1 commit into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Add streams to the stream list on the homepage in the order they were added
* Add firmware version for main and expansion units on About page
* Limit length of displayed stream names with ellipsis
* Minor security increase to Pandora passwords
* Add restart stream button to stream player and stream modal
* Add dynamic scaling to controls on Player page
* System
Expand Down
47 changes: 32 additions & 15 deletions web/src/pages/Settings/Streams/StreamModal/StreamModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ const RESTART_DESC = "Sometimes the stream gets into a bad state and neds to be

// We're already using mui, why are we reinventing the wheel? https://mui.com/material-ui/react-text-field/
// if it's a matter of className control on the underlying components, that still works with the mui textfield with the InputLabelProps prop and other componentProps
Comment on lines 15 to 16
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://mui.com/material-ui/react-text-field/
I forgot about us recreating the TextField manually
I still hate it, but this time around I'm gonna make an issue out of that and solve it myself

const TextField = ({ name, desc, defaultValue, onChange }) => {
const TextField = ({ name, desc, type="text", defaultValue, onChange }) => {

return (
<>
<div className="stream-field">
<div className="stream-field-name">{name}</div>
<input
type="text"
type={type}
defaultValue={defaultValue}
onChange={(e) => {
onChange(e.target.value);
Expand All @@ -35,6 +36,7 @@ const TextField = ({ name, desc, defaultValue, onChange }) => {
TextField.propTypes = {
name: PropTypes.string.isRequired,
desc: PropTypes.string.isRequired,
type: PropTypes.string,
defaultValue: PropTypes.string,
onChange: PropTypes.func.isRequired,
};
Expand Down Expand Up @@ -209,19 +211,34 @@ const StreamModal = ({ stream, onClose, apply, del }) => {
// Render fields from StreamFields.json
streamTemplate.fields.map((field) => {
switch (field.type) {
case "text":
return (
<TextField
key={field.name}
name={field.name}
desc={field.desc}
required={field.required}
defaultValue={streamFields[field.name]}
onChange={(v) => {
setStreamFields({ ...streamFields, [field.name]: v });
}}
/>
);
case "text":
return (
<TextField
key={field.name}
name={field.name}
desc={field.desc}
type={"text"}
required={field.required}
defaultValue={streamFields[field.name]}
onChange={(v) => {
setStreamFields({ ...streamFields, [field.name]: v });
}}
/>
);
case "password":
return (
<TextField
key={field.name}
name={field.name}
desc={field.desc}
type={"password"}
required={field.required}
defaultValue={streamFields[field.name]}
onChange={(v) => {
setStreamFields({ ...streamFields, [field.name]: v });
}}
/>
);
case "bool":
return (
<BoolField
Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/Settings/Streams/StreamTemplates.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
{
"title": "Pandora Password",
"name": "password",
"type": "text",
"type": "password",
"required": true
}
]
Expand Down
Loading