fixed api stuff

This commit is contained in:
2024-05-22 19:57:02 +03:00
parent a6a63805e4
commit 106b7326f2
6 changed files with 82 additions and 28 deletions

View File

@@ -18,12 +18,18 @@ type Connection struct {
connection *mongo.Client
}
type UserResponse struct {
Username string
Permissions models.Permission
Email string
}
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 []models.User
var response []UserResponse
err = users.All(context.TODO(), &response)
@@ -34,12 +40,6 @@ func (con Connection) GetUsers(c *gin.Context) {
c.IndentedJSON(http.StatusOK, response)
}
type UserResponse struct {
Username string
Permissions models.Permission
Email string
}
func (con Connection) GetUser(c *gin.Context) {
claims, exists := c.Get("claims")
if !exists {