Sfoglia il codice sorgente

Prevent settings a blank password

Pjotir 1 anno fa
parent
commit
1274e7acc2
1 ha cambiato i file con 4 aggiunte e 0 eliminazioni
  1. 4 0
      app/main.py

+ 4 - 0
app/main.py

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