This repository has been archived on 2025-10-08. You can view files and clone it, but cannot push or open issues or pull requests.
miniauthold/pkg/web/web.go
kekskurse 6962d40d78
Some checks failed
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/push/playwright Pipeline failed
ci/woodpecker/push/deplyoment unknown status
add globale config
2025-03-14 01:49:49 +01:00

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)
}