This commit is contained in:
2025-03-13 21:18:01 +02:00
parent 02adc8b545
commit fd957e32b9
28 changed files with 1064 additions and 457 deletions

View File

@@ -6,6 +6,7 @@ import (
"net/http"
"git.acooldomain.co/server-manager/backend-kubernetes-go/auth"
"git.acooldomain.co/server-manager/backend-kubernetes-go/dbhandler"
"git.acooldomain.co/server-manager/backend-kubernetes-go/mail"
"git.acooldomain.co/server-manager/backend-kubernetes-go/models"
"github.com/gin-gonic/gin"
@@ -15,29 +16,24 @@ import (
)
type Connection struct {
connection *mongo.Client
connection *dbhandler.UsersDBHandler
config *models.GlobalConfig
}
type UserResponse struct {
Username string
Permissions models.Permission
Email string
Permissions models.Permission
}
func (con Connection) GetUsers(c *gin.Context) {
users, err := con.connection.Database("Backend").Collection("Users").Find(context.TODO(), bson.D{})
if err != nil {
panic(err)
}
var response []UserResponse
err = users.All(context.TODO(), &response)
users, err := (*con.connection).ListUsers()
if err != nil {
panic(err)
}
c.IndentedJSON(http.StatusOK, response)
c.JSON(http.StatusOK, users)
}
func (con Connection) GetUser(c *gin.Context) {