disable /register if a user exist
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user