func (s *ApiServer) PostUser(c *gin.Context) {
	newUser := users.User{}
	if err := c.ShouldBindJSON(&newUser); err != nil {
		c.JSON(http.StatusBadRequest, ApiError{Message: err.Error()})
		return
	}
	if user := s.s.users.GetUserUnscoped(newUser.Email); user != nil {
		c.JSON(http.StatusBadRequest, ApiError{Message: "user already exists"})
		return
	}
	if err := s.s.CreateUser(newUser, s.s.wg.Cfg.GetDefaultDeviceName()); err != nil {
		c.JSON(http.StatusInternalServerError, ApiError{Message: err.Error()})
		return
	}
	user := s.s.users.GetUserUnscoped(newUser.Email)
	if user == nil {
		c.JSON(http.StatusNotFound, ApiError{Message: "user not found"})
		return
	}
	c.JSON(http.StatusOK, user)
}
PostUser godoc
@Tags Users
@Summary Creates a new user based on the given user model
@ID PostUser
@Accept  json
@Produce json
@Param User body users.User true "User Model"
@Success 200 {object} users.User
@Failure 400 {object} ApiError
@Failure 401 {object} ApiError
@Failure 403 {object} ApiError
@Failure 404 {object} ApiError
@Failure 500 {object} ApiError
@Router /backend/users [post]
@Security ApiBasicAuth
package server
import (
	"encoding/json"
	"net/http"
	"strings"
	"time"
	jsonpatch "github.com/evanphx/json-patch"
	"github.com/gin-gonic/gin"
	"github.com/h44z/wg-portal/internal/common"
	"github.com/h44z/wg-portal/internal/users"
	"github.com/h44z/wg-portal/internal/wireguard"
)
type ApiServer struct {
	s *Server
}
type ApiError struct {
	Message string
}
func (s *ApiServer) GetUsers(c *gin.Context) {
	allUsers := s.s.users.GetUsersUnscoped()
	c.JSON(http.StatusOK, allUsers)
}
func (s *ApiServer) GetUser(c *gin.Context) {
	email := strings.ToLower(strings.TrimSpace(c.Query("Email")))
	if email == "" {
		c.JSON(http.StatusBadRequest, ApiError{Message: "Email parameter must be specified"})
		return
	}
	user := s.s.users.GetUserUnscoped(email)
	if user == nil {
		c.JSON(http.StatusNotFound, ApiError{Message: "user not found"})
		return
	}
	c.JSON(http.StatusOK, user)
}