diff --git a/http/http.go b/http/http.go index 3f385e2..77e71d7 100644 --- a/http/http.go +++ b/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) } diff --git a/templates/register.html b/templates/register.html new file mode 100644 index 0000000..35a44e7 --- /dev/null +++ b/templates/register.html @@ -0,0 +1,50 @@ +{{define "register"}} + + + + Registration + + {{template "head"}} + + + + + +
+
+ +
+ + +
+ + +
+ + +
+ +
+ The entered credentials are invalid +
+ + +
+
+ + +{{end}} \ No newline at end of file