Add registration
This commit is contained in:
10
http/http.go
10
http/http.go
@ -29,6 +29,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)
|
||||
api := router.Group("/api/v1")
|
||||
{
|
||||
api.GET("/logout", logout)
|
||||
@ -85,6 +86,15 @@ func (h *Handler) login(c *gin.Context) {
|
||||
c.HTML(http.StatusOK, "login", nil)
|
||||
}
|
||||
|
||||
func (h *Handler) register(c *gin.Context) {
|
||||
if _, err := h.verifyLogin(c); err == nil {
|
||||
c.Redirect(http.StatusTemporaryRedirect, "/api/v1/hello")
|
||||
return
|
||||
}
|
||||
|
||||
c.HTML(http.StatusOK, "register", nil)
|
||||
}
|
||||
|
||||
func logout(c *gin.Context) {
|
||||
clearLogin(c)
|
||||
}
|
||||
|
Reference in New Issue
Block a user