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

@ -9,26 +9,18 @@ import (
)
func (h *Handler) dashboard(c *gin.Context) {
token, err := h.verifyLogin(c)
if err != nil {
c.Redirect(http.StatusTemporaryRedirect, "/login")
return
}
userID := token.GetID()
userID := c.MustGet("token").(budgeteer.Token).GetID()
budgets, err := h.Service.BudgetsForUser(userID)
if err != nil {
return
}
d := DashboardData{
Token: token,
Budgets: budgets,
}
c.HTML(http.StatusOK, "dashboard.html", d)
}
type DashboardData struct {
Token budgeteer.Token
Budgets []postgres.Budget
}