fix: check user exists on login
This commit is contained in:
parent
51c33543e8
commit
f03e4eae65
|
|
@ -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
|
||||
|
|
|
|||
3
main.go
3
main.go
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue