diff --git a/back_end/Helena_de_troia b/back_end/Helena_de_troia index a3a161a..a7c0165 100755 Binary files a/back_end/Helena_de_troia and b/back_end/Helena_de_troia differ diff --git a/back_end/func_db.go b/back_end/func_db.go index a6ff3c4..2c17a19 100644 --- a/back_end/func_db.go +++ b/back_end/func_db.go @@ -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 } diff --git a/back_end/main.go b/back_end/main.go index c583bfb..1921ca5 100644 --- a/back_end/main.go +++ b/back_end/main.go @@ -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, })) diff --git a/back_end/rotas.go b/back_end/rotas.go index dbea0d8..ea9e9a9 100644 --- a/back_end/rotas.go +++ b/back_end/rotas.go @@ -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 { diff --git a/rpg/index.html b/rpg/index.html index 46de0b6..90a774c 100644 --- a/rpg/index.html +++ b/rpg/index.html @@ -9,9 +9,9 @@