Remove login test-routes

This commit is contained in:
Jan Bader 2016-12-31 03:28:29 +01:00
parent 917251a16e
commit 9a399c13a3

View File

@ -38,17 +38,6 @@ func (h *Handler) Serve() {
api.GET("/login", func(c *gin.Context) { c.Redirect(http.StatusPermanentRedirect, "/login") }) api.GET("/login", func(c *gin.Context) { c.Redirect(http.StatusPermanentRedirect, "/login") })
api.POST("/login", h.loginPost) api.POST("/login", h.loginPost)
api.POST("/register", h.registerPost) api.POST("/register", h.registerPost)
// Unauthenticated routes
api.GET("/check", func(c *gin.Context) { c.String(http.StatusOK, "Accessible") })
api.GET("/hello", func(c *gin.Context) { c.String(http.StatusOK, "Hello, World!") })
// Restricted group
r := api.Group("/restricted")
{
//r.Use(middleware.JWT([]byte(secret)))
r.GET("", h.restricted)
}
} }
router.Run(":1323") router.Run(":1323")
@ -68,17 +57,6 @@ func (h *Handler) dashboard(c *gin.Context) {
c.HTML(http.StatusOK, "dashboard", d) c.HTML(http.StatusOK, "dashboard", d)
} }
func (h *Handler) restricted(c *gin.Context) {
token, err := h.verifyLogin(c)
if err != nil {
c.Redirect(http.StatusTemporaryRedirect, "/login")
return
}
name := token.GetName()
c.String(http.StatusOK, "Welcome "+name+"!")
}
func (h *Handler) verifyLogin(c *gin.Context) (budgeteer.Token, error) { func (h *Handler) verifyLogin(c *gin.Context) (budgeteer.Token, error) {
tokenString, err := c.Cookie(authCookie) tokenString, err := c.Cookie(authCookie)
if err != nil { if err != nil {