Add dashboard
This commit is contained in:
11
http/http.go
11
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 {
|
||||
|
Reference in New Issue
Block a user