Skip to content

Commit

Permalink
fix: do not require change password to change reporting configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
jajjibhai008 committed Jul 10, 2023
1 parent f0ea4b0 commit adc26e8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/components/ReportingConfig/ReportingConfigForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ class ReportingConfigForm extends React.Component {
* @param {FormData} formData
* @param {[String]} requiredFields
*/
validateReportingForm = (formData, requiredFields) => {
validateReportingForm = (config, formData, requiredFields) => {
const invalidFields = requiredFields
.filter(field => !formData.get(field))
.reduce((prevFields, currField) => ({ ...prevFields, [currField]: true }), {});

// Password is conditionally required only when pgp key will not be present
// and delivery method is email
if (!formData.get('pgpEncryptionKey') && formData.get('deliveryMethod') === 'email') {
if (!formData.get('encryptedPassword')) {
if (!formData.get('encryptedPassword') && !config?.encryptedPassword) {
invalidFields.encryptedPassword = true;
}
}
Expand Down Expand Up @@ -131,7 +131,7 @@ class ReportingConfigForm extends React.Component {
requiredFields = config ? [...REQUIRED_SFTP_FIELDS] : [...REQUIRED_NEW_SFTP_FEILDS];
}
// validate the form
const invalidFields = this.validateReportingForm(formData, requiredFields);
const invalidFields = this.validateReportingForm(config, formData, requiredFields);
// if there are invalid fields, reflect that in the UI
if (!isEmpty(invalidFields)) {
this.setState((state) => ({
Expand Down

0 comments on commit adc26e8

Please sign in to comment.