fixed a big oops

This commit is contained in:
grumbulon 2022-12-31 13:23:09 -05:00
parent e2fbc9b1a1
commit ec4a7ed396

View file

@ -23,10 +23,6 @@ func Login(w http.ResponseWriter, r *http.Request) {
username := r.Form.Get("username")
if username == "" {
username = autoUname()
}
password := r.Form.Get("password")
if password == "" {
@ -40,8 +36,12 @@ func Login(w http.ResponseWriter, r *http.Request) {
return
}
db.Model(internal.User{Username: username}).First(&result)
db.Where("username = ?", username).First(&result)
if result.Username == "" {
http.Error(w, "User not registered", http.StatusUnauthorized)
return
}
err = bcrypt.CompareHashAndPassword([]byte(result.HashedPassword), []byte(password))
if err != nil {