Save hashed PW. Simplify model update. Bugfixes & improvements. Working user-settings & games.

This commit is contained in:
MaxJa4
2024-01-18 19:00:32 +01:00
parent f8ac93f163
commit f2ab72ba1e
20 changed files with 310 additions and 113 deletions

View File

@@ -1,7 +1,8 @@
package controllers
import (
"InfrantrySkillCalculator/models"
"InfantrySkillCalculator/models"
"fmt"
"github.com/gin-gonic/gin"
"gorm.io/gorm"
"net/http"
@@ -25,6 +26,21 @@ func GetGames(c *gin.Context) {
c.JSON(http.StatusOK, games)
}
// GetGamesHTML GET /game_html
func GetGamesHTML(c *gin.Context) {
var games []models.Game
models.DB.Find(&games)
var htmlOptions string
htmlOptions = `<option disabled selected value>Auswählen...</option>`
for _, game := range games {
htmlOptions += fmt.Sprintf(`<option value="%d">%s</option>`, game.ID, game.Name)
}
c.Header("Content-Type", "text/html")
c.String(http.StatusOK, htmlOptions)
}
// GetGameByID GET /game/:id
func GetGameByID(c *gin.Context) {
var game models.Game