Remove token from data and add to gin context

This commit is contained in:
2021-12-02 20:04:18 +00:00
parent e7c9a7f52f
commit 36bccce021
4 changed files with 13 additions and 29 deletions

View File

@ -3,24 +3,16 @@ package http
import (
"net/http"
"git.javil.eu/jacob1123/budgeteer"
"git.javil.eu/jacob1123/budgeteer/postgres"
"github.com/gin-gonic/gin"
"github.com/google/uuid"
)
type AccountData struct {
Token budgeteer.Token
Accounts []postgres.Account
}
func (h *Handler) accounts(c *gin.Context) {
token, err := h.verifyLogin(c)
if err != nil {
c.Redirect(http.StatusTemporaryRedirect, "/login")
return
}
budgetID := c.Param("budgetid")
budgetUUID, err := uuid.Parse(budgetID)
if err != nil {
@ -35,9 +27,17 @@ func (h *Handler) accounts(c *gin.Context) {
}
d := AccountData{
Token: token,
Accounts: accounts,
}
c.HTML(http.StatusOK, "accounts.html", d)
}
type AdminData struct {
}
func (h *Handler) admin(c *gin.Context) {
d := AdminData{}
c.HTML(http.StatusOK, "accounts.html", d)
}