fix: check user exists on login

This commit is contained in:
Teajey 2024-05-08 01:11:40 +12:00
parent 51c33543e8
commit f03e4eae65
Signed by: Teajey
GPG Key ID: 970E790FE834A713
2 changed files with 1 additions and 4 deletions

View File

@ -19,7 +19,7 @@ func (auth *AuthMiddleware) LoginPost(w http.ResponseWriter, r *http.Request) {
password := r.Form.Get("password")
user, err := db.GetUserByName(username)
if err != nil {
if user == nil || err != nil {
time.Sleep(time.Second)
http.Error(w, "Username or password invalid", http.StatusUnauthorized)
return

View File

@ -41,9 +41,6 @@ func main() {
protectedMux.HandleFunc("POST /wishlist/delete", ctx.WishlistDelete)
protectedMux.HandleFunc("POST /logout", authMiddleware.LogoutPost)
// TODO: Remove me
protectedMux.HandleFunc("GET /logout", authMiddleware.LogoutPost)
http.Handle("/", authMiddleware)
http.ListenAndServe(":4000", nil)