Răsfoiți Sursa

corrected header/body orderings

Alexander Belanger 5 ani în urmă
părinte
comite
3b9e67815f
1 a modificat fișierele cu 4 adăugiri și 4 ștergeri
  1. 4 4
      server/api/user_handler.go

+ 4 - 4
server/api/user_handler.go

@@ -69,12 +69,12 @@ func (app *App) HandleAuthCheck(w http.ResponseWriter, r *http.Request) {
 
 	userID, _ := session.Values["user_id"].(uint)
 
+	w.WriteHeader(http.StatusOK)
+
 	if err := app.sendUserID(w, userID); err != nil {
 		app.handleErrorFormDecoding(err, ErrUserDecode, w)
 		return
 	}
-
-	w.WriteHeader(http.StatusOK)
 }
 
 // HandleLoginUser checks the request header for cookie and validates the user.
@@ -119,12 +119,12 @@ func (app *App) HandleLoginUser(w http.ResponseWriter, r *http.Request) {
 		app.logger.Warn().Err(err)
 	}
 
+	w.WriteHeader(http.StatusOK)
+
 	if err := app.sendUserID(w, storedUser.ID); err != nil {
 		app.handleErrorFormDecoding(err, ErrUserDecode, w)
 		return
 	}
-
-	w.WriteHeader(http.StatusOK)
 }
 
 // HandleLogoutUser detaches the user from the session