34 lines
611 B
Go
34 lines
611 B
Go
package web
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
type WebConfig struct {
|
|
PublicRegistration bool `env:"PUBLIC_REGISTRATION, default=0"`
|
|
}
|
|
|
|
type Web struct {
|
|
config WebConfig
|
|
}
|
|
|
|
func NewWeb(config WebConfig) Web {
|
|
w := Web{}
|
|
w.config = config
|
|
return w
|
|
}
|
|
|
|
func (w Web) RegisterRoutes(routing *gin.RouterGroup) error {
|
|
routing.GET("/register", w.GetRegisterPage)
|
|
return nil
|
|
}
|
|
|
|
func (w Web) GetRegisterPage(c *gin.Context) {
|
|
if !w.config.PublicRegistration {
|
|
c.HTML(403, "msg.html", gin.H{"msg": "Public registration disabled"})
|
|
return
|
|
}
|
|
c.HTML(http.StatusOK, "register.html", nil)
|
|
}
|