mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-05-01 10:42:24 +02:00
project edit form: allow empty private code (= no change)
Currently, the private code is mandatory in the edit form, and it's not clear whether it's meant to **check** for the right private code or to **change** the private code. Make the field optional and rename the help message to make it clearer it's only meant to **change** the private code. Also change the field type to "password" instead of simple string.
This commit is contained in:
parent
856412a70d
commit
ec1e6cf26e
1 changed files with 9 additions and 3 deletions
|
@ -103,7 +103,8 @@ class CalculatorStringField(StringField):
|
|||
|
||||
class EditProjectForm(FlaskForm):
|
||||
name = StringField(_("Project name"), validators=[DataRequired()])
|
||||
password = StringField(_("Private code"), validators=[DataRequired()])
|
||||
# If empty -> don't change the password
|
||||
password = PasswordField(_("New private code"))
|
||||
contact_email = StringField(_("Email"), validators=[DataRequired(), Email()])
|
||||
project_history = BooleanField(_("Enable project history"))
|
||||
ip_recording = BooleanField(_("Use IP tracking for project history"))
|
||||
|
@ -154,8 +155,13 @@ class EditProjectForm(FlaskForm):
|
|||
"""Update the project with the information from the form"""
|
||||
project.name = self.name.data
|
||||
|
||||
# Only update password if changed to prevent spurious log entries
|
||||
if not check_password_hash(project.password, self.password.data):
|
||||
if (
|
||||
# Only update password if a new one is provided
|
||||
self.password.data
|
||||
# Only update password if different from the previous one,
|
||||
# to prevent spurious log entries
|
||||
and not check_password_hash(project.password, self.password.data)
|
||||
):
|
||||
project.password = generate_password_hash(self.password.data)
|
||||
|
||||
project.contact_email = self.contact_email.data
|
||||
|
|
Loading…
Reference in a new issue