Преглед изворни кода

Prevent settings a blank password

Pjotir пре 1 година
родитељ
комит
1274e7acc2
1 измењених фајлова са 4 додато и 0 уклоњено
  1. 4 0
      app/main.py

+ 4 - 0
app/main.py

@@ -170,6 +170,10 @@ def login():
                 return redirect(url_for("login"))
 
             if not user.passhash:
+                if not password:
+                    flash("Can't set a blank password")
+                    return redirect(url_for("login"))
+                
                 salt = bcrypt.gensalt()
                 user.passhash = bcrypt.hashpw(password.encode(), salt)
                 db.session.commit()