~roshless/nnrss

08f72a4fe68f62c066fbe464331dd33ce23b42f3 — Roshless 4 months ago 7faff4e
bugfix: dont force user to change their password
2 files changed, 9 insertions(+), 5 deletions(-)

M nnrss/forms.py
M nnrss/views.py
M nnrss/forms.py => nnrss/forms.py +3 -2
@@ 32,8 32,9 @@ class RegistrationForm(Form):


class SettingsForm(Form):
    password = StringField("Password", [validators.Length(min=5, max=35)])
    api_key = StringField("API key", [validators.Length(min=8, max=35)])
    # needs 200 chars for hash
    password = StringField("Password", [validators.Length(min=5, max=200)])
    api_key = StringField("API key", [validators.Length(min=8, max=100)])
    update_interval = IntegerField(
        "Update interval in minutes", [validators.NumberRange(min=5, max=2880)]
    )

M nnrss/views.py => nnrss/views.py +6 -3
@@ 232,9 232,12 @@ def settings():
    user_prefs = handler.get_user(session["logged_in"])
    form = SettingsForm(request.form, user_prefs)
    if request.method == "POST" and form.validate():
        user_prefs.password = generate_password_hash(
            form.password.data, method="pbkdf2:sha512"
        )
        if form.password.data.startswith("pbkdf2"):
            user_prefs.password = form.password.data
        else:
            user_prefs.password = generate_password_hash(
                form.password.data, method="pbkdf2:sha512"
            )
        user_prefs.api_key = form.api_key.data
        user_prefs.update_interval = form.update_interval.data
        handler.add_user(user_prefs)