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

Change Password Requirement for IEC Security #374

Merged
merged 3 commits into from
Aug 13, 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
2 changes: 1 addition & 1 deletion packages/react-components/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.8.53",
"version": "0.8.54",
"license": "MIT",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
Expand Down
17 changes: 10 additions & 7 deletions packages/react-components/src/Accounts/Accounts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const Accounts: React.FC<UserGroupProps> = ({ host, token, userGroupsDefaultSele
const [deletedDialog, setDeletedDialog] = useState(false);
const [deleteRow, setDeleteRow] = useState({});
const [filteringColumnExtensions, setFilteringColumnExtensions] = useState([]);
const [errorMessage, setErrorMessage] = useState('');
sude-dewi marked this conversation as resolved.
Show resolved Hide resolved
const getRowId = (row) => row.id;

const metadataHeader = metadata
Expand Down Expand Up @@ -129,21 +130,22 @@ const Accounts: React.FC<UserGroupProps> = ({ host, token, userGroupsDefaultSele

const handleSubmit = (row, isNew = false) => {
if (isNew) {
return (
createAccount(host, token, { ...row }).subscribe(() => {
return createAccount(host, token, { ...row }).subscribe(
() => {
fetchData();
}),
},
(error) => {
console.log('Create Account: ', error);
}
);
} else {
return (
updateAccount(host, token, { ...row }).subscribe(() => {
return updateAccount(host, token, { ...row }).subscribe(
() => {
fetchData();
}),
},
(error) => {
console.log('Update Accounts: ', error);
setErrorMessage('Passwords must be at least 7 characters');
console.log('Update Account: ', error);
}
);
}
Expand Down Expand Up @@ -202,6 +204,7 @@ const Accounts: React.FC<UserGroupProps> = ({ host, token, userGroupsDefaultSele
onSave={handleSubmit}
hasPassword
userGroupsDefaultSelected={userGroupsDefaultSelected}
errorMessage={errorMessage}
/>
<Toolbar />
<TableColumnVisibility />
Expand Down
11 changes: 8 additions & 3 deletions packages/react-components/src/common/Table/Popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const Popup: React.FC<PopupProps> = ({
metadata,
hasPassword,
userGroupsDefaultSelected,
errorMessage,
}) => {
const [error, setError] = useState<boolean>(false);
const [passwordStrengthColor, setPasswordStrengthColor] = useState('red');
Expand Down Expand Up @@ -141,7 +142,8 @@ const Popup: React.FC<PopupProps> = ({
variant="standard"
required={isNew}
value={row.password || ''}
error={!passwordValid}
error={!passwordValid || errorMessage!==''}
helperText={errorMessage}
InputProps={{ endAdornment }}
onChange={onChange}
autoComplete="new-password"
Expand All @@ -156,9 +158,12 @@ const Popup: React.FC<PopupProps> = ({
required={isNew}
label="Repeat Password"
value={row.repeatPassword || ''}
error={!passwordValid}
error={!passwordValid || errorMessage!==''}
onChange={onChange}
helperText={!passwordValid && 'Passwords do not match'}
helperText={
(!passwordValid && 'Passwords do not match') ||
errorMessage
}
autoComplete="new-password"
/>
</>
Expand Down
4 changes: 3 additions & 1 deletion packages/react-components/src/common/Table/PopupEditing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const PopupEditing = React.memo(
onSave,
hasPassword,
userGroupsDefaultSelected,
errorMessage,
}: PopupEditingProps) => (
<Plugin>
<Template name="popupEditing">
Expand Down Expand Up @@ -141,7 +142,7 @@ const PopupEditing = React.memo(
}
};

const open = editingRowIds.length > 0 || isNew;
const open = editingRowIds.length > 0 || isNew || errorMessage!=='';

return (
<Popup
Expand All @@ -160,6 +161,7 @@ const PopupEditing = React.memo(
metadata={metadata}
hasPassword={hasPassword}
userGroupsDefaultSelected={userGroupsDefaultSelected}
errorMessage={errorMessage}
/>
);
}}
Expand Down
2 changes: 2 additions & 0 deletions packages/react-components/src/common/Table/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export interface PopupEditingProps {
* Set User Groups default list when creating a new Account
*/
userGroupsDefaultSelected?: string[];
errorMessage?: string;
}

export interface PopupProps {
Expand Down Expand Up @@ -142,6 +143,7 @@ export interface PopupProps {
* Set User Groups default list when creating a new Account
*/
userGroupsDefaultSelected?: string[];
errorMessage?: string;
}

export interface MetadataEditorProps {
Expand Down
Loading