Remove token from data and add to gin context
This commit is contained in:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user