From ca1c2ed778d45aae6c8fe7dac2107ac8b70b1211 Mon Sep 17 00:00:00 2001 From: Jan Bader Date: Tue, 20 Dec 2016 20:05:15 +0100 Subject: [PATCH] Add dashboard --- http/http.go | 11 +++++++++++ templates/dashboard.html | 20 ++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 templates/dashboard.html diff --git a/http/http.go b/http/http.go index ed39fc7..edad182 100644 --- a/http/http.go +++ b/http/http.go @@ -31,6 +31,7 @@ func (h *Handler) Serve() { router.GET("/", func(c *gin.Context) { c.HTML(http.StatusOK, "index", nil) }) router.GET("/login", h.login) router.GET("/register", h.register) + router.GET("/dashboard", h.dashboard) api := router.Group("/api/v1") { api.GET("/logout", logout) @@ -53,6 +54,16 @@ func (h *Handler) Serve() { router.Run(":1323") } +func (h *Handler) dashboard(c *gin.Context) { + token, err := h.verifyLogin(c) + if err != nil { + c.Redirect(http.StatusTemporaryRedirect, "/login") + return + } + + c.HTML(http.StatusOK, "dashboard", token) +} + func (h *Handler) restricted(c *gin.Context) { token, err := h.verifyLogin(c) if err != nil { diff --git a/templates/dashboard.html b/templates/dashboard.html new file mode 100644 index 0000000..dc8dd7c --- /dev/null +++ b/templates/dashboard.html @@ -0,0 +1,20 @@ +{{define "dashboard"}} + + + + Registration + + {{template "head"}} + + + +
+ +
+ + +{{end}} \ No newline at end of file