Use uuid.UUID everywhere and have postgres generate ids

This commit is contained in:
2021-11-29 21:49:37 +00:00
parent 5e8a98872f
commit 85ef7557c1
19 changed files with 199 additions and 93 deletions

View File

@ -14,6 +14,7 @@ import (
"git.javil.eu/jacob1123/budgeteer/web"
"github.com/gin-gonic/gin"
"github.com/google/uuid"
)
// Handler handles incoming requests
@ -72,7 +73,13 @@ func (h *Handler) budget(c *gin.Context) {
}
budgetID := c.Param("budgetid")
budget, err := h.Service.DB.GetBudget(context.Background(), budgetID)
budgetUUID, err := uuid.Parse(budgetID)
if err != nil {
c.Redirect(http.StatusTemporaryRedirect, "/login")
return
}
budget, err := h.Service.DB.GetBudget(context.Background(), budgetUUID)
if err != nil {
c.AbortWithError(http.StatusUnauthorized, err)
return