correção do bugs e melhora nos cookies

This commit is contained in:
2025-06-28 22:50:10 -03:00
parent bd4503ac37
commit 61f7cd28dc
20 changed files with 51 additions and 32 deletions

Binary file not shown.

View File

@@ -37,13 +37,13 @@ func sessionCookie(id int, player string) (*http.Cookie, error) {
}
cookie := &http.Cookie{
Name: cookieName,
Value: sessionID,
Path: "/",
//HttpOnly: true,
//Secure: true,
//SameSite: http.SameSiteNoneMode,
Expires: time.Now().Add(time.Duration(sessionTime) * time.Hour),
Name: cookieName,
Value: sessionID,
Path: "/",
HttpOnly: true,
Secure: true,
SameSite: http.SameSiteNoneMode,
Expires: time.Now().Add(time.Duration(sessionTime) * time.Hour),
}
return cookie, nil
}

View File

@@ -44,8 +44,20 @@ func main() {
if !ok || siteUnlock == "" {
log.Fatal("Erro: siteUnlock ausente ou não é string")
}
e.Pre(func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
if proto := c.Request().Header.Get("X-Forwarded-Proto"); proto != "" {
c.Request().URL.Scheme = proto
}
return next(c)
}
})
e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
AllowOrigins: []string{siteUnlock},
AllowMethods: []string{http.MethodGet, http.MethodPost, http.MethodPatch},
AllowHeaders: []string{"Content-Type"},
AllowCredentials: true,
}))

View File

@@ -350,12 +350,19 @@ func player_updateInputs(c echo.Context) error {
lore := c.FormValue("lore")
if vida != "" {
a, _ := strconv.Atoi(vida)
if a < 1 {
return jsonError(c, http.StatusUnauthorized, "o seu merda, sua viada não pode ser 0 ou inferior.")
}
err := updateField("UPDATE players SET vida=?, vida_maxima=? WHERE id=?;", vida, vida, session["user_id"])
if err != nil {
return jsonError(c, http.StatusInternalServerError, "erro ao alterar sua vida.")
}
lista = append(lista, "vida")
}
if nome != "" {
err := updateField("UPDATE players SET nome=? WHERE id=?;", nome, session["user_id"])
if err != nil {