If you create a download and apply a password it works.
If you then come back and remove the tick from the “Enable Password Lock”, but leave the original password in the associated text field, the system still asks for a password in the UI.
Your code seems to be checking for the existence of a password in the associated text field only. It should check the status of the “Enable Password Lock” first, and IF that is set to TRUE, only then apply the password validation component.
The work around is to re-enable the tick box, remove the original password from the text box, and then un check the tick box again.
If you do this, the password validation is not required.
A solution could also be to simply wipe clean the password text field when the tick box is un-checked. This would solve it probably.