Move dashboard to api
This commit is contained in:
parent
929db00a47
commit
ddab5998bc
@ -49,7 +49,6 @@ func (h *Handler) Serve() {
|
||||
|
||||
withLogin := router.Group("")
|
||||
withLogin.Use(h.verifyLoginWithRedirect)
|
||||
withLogin.GET("/dashboard", h.dashboard)
|
||||
withLogin.GET("/admin", h.admin)
|
||||
withLogin.GET("/admin/clear-database", h.clearDatabase)
|
||||
|
||||
@ -75,6 +74,7 @@ func (h *Handler) Serve() {
|
||||
|
||||
authenticated := api.Group("")
|
||||
authenticated.Use(h.verifyLoginWithRedirect)
|
||||
authenticated.GET("/dashboard", h.dashboard)
|
||||
|
||||
user := authenticated.Group("/user")
|
||||
user.GET("/logout", logout)
|
||||
|
@ -26,6 +26,18 @@ func (h *Handler) verifyLogin(c *gin.Context) (budgeteer.Token, error) {
|
||||
return token, nil
|
||||
}
|
||||
|
||||
func (h *Handler) verifyLoginWithForbidden(c *gin.Context) {
|
||||
token, err := h.verifyLogin(c)
|
||||
if err != nil {
|
||||
//c.Header("WWW-Authenticate", "Bearer")
|
||||
c.AbortWithStatus(http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
||||
c.Set("token", token)
|
||||
c.Next()
|
||||
}
|
||||
|
||||
func (h *Handler) verifyLoginWithRedirect(c *gin.Context) {
|
||||
token, err := h.verifyLogin(c)
|
||||
if err != nil {
|
||||
|
@ -12,7 +12,7 @@ const store = createStore({
|
||||
},
|
||||
mutations: {
|
||||
getDashboard (state) {
|
||||
fetch("/dashboard")
|
||||
fetch("/api/v1/dashboard")
|
||||
.then(x => x.json())
|
||||
.then(x => console.log(x))
|
||||
.then(x => state.Budgets = x.Budgets);
|
||||
|
Loading…
x
Reference in New Issue
Block a user