Remove login test-routes
This commit is contained in:
parent
917251a16e
commit
9a399c13a3
22
http/http.go
22
http/http.go
@ -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 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user