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

Fix: PDFPasswordForm loads the PDF even when password validation fails #23463

Merged
Changes from 1 commit
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
16 changes: 10 additions & 6 deletions src/components/PDFView/PDFPasswordForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,17 @@ class PDFPasswordForm extends Component {
}

validate() {
if (!_.isEmpty(this.state.password)) {
return true;
if (this.props.isPasswordInvalid) {
return false;
}
if (_.isEmpty(this.state.password)) {
this.setState({
validationErrorText: 'attachmentView.passwordRequired',
});
return false;
}
this.setState({
validationErrorText: 'attachmentView.passwordRequired',
});
return false;

return true;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we rewrite this so we only return false in one place?

if (!_.isEmpty(this.state.password) && !this.props.isPasswordInvalid) {
    return true;
}

if (_.isEmpty(this.state.password)) {
...
}

return false;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated!

}

validateAndNotifyPasswordBlur() {
Expand Down