disable /register if a user exist

This commit is contained in:
2025-04-14 22:55:36 +02:00
parent 98c75c111f
commit cca0b2775c
3 changed files with 53 additions and 5 deletions

View File

@@ -2,7 +2,6 @@ package controllers
import (
"fmt"
"math/rand"
"net/http"
"github.com/gin-gonic/gin"
@@ -182,6 +181,38 @@ func (rc *UserController) RegisterView(c *gin.Context) {
c.HTML(http.StatusOK, "register.html", data)
}
func (rc *UserController) InitAdmin(c *gin.Context) {
isEmpty, err := repositories.Users.IsEmpty()
if err != nil {
data := gin.H{
"error": err,
"success": "",
}
c.HTML(http.StatusInternalServerError, "error.html", data)
return
}
if !isEmpty {
data := gin.H{
"error": "Registration is closed",
"success": "",
}
c.HTML(http.StatusInternalServerError, "error.html", data)
return
}
data := gin.H{
"error": "",
"success": "",
}
c.HTML(http.StatusOK, "register.html", data)
}
func (rc *UserController) ResetView(c *gin.Context) {
shopItems, _ := repositories.ShopItems.GetAll()