fixed some broken APIs
This commit is contained in:
@@ -98,10 +98,26 @@ func (con Connection) SetUserPermissions(c *gin.Context) {
|
||||
c.JSON(200, "OK")
|
||||
}
|
||||
|
||||
func (con Connection) DeleteUser(c *gin.Context) {
|
||||
username := c.Param("user_id")
|
||||
|
||||
_, err := con.connection.Database("Backend").Collection("Users").DeleteOne(
|
||||
context.TODO(),
|
||||
bson.D{{Key: "Username", Value: username}},
|
||||
)
|
||||
if err != nil {
|
||||
c.AbortWithError(500, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(200, "OK")
|
||||
}
|
||||
|
||||
func LoadGroup(group *gin.RouterGroup, client *mongo.Client, config models.GlobalConfig) {
|
||||
connection := Connection{connection: client}
|
||||
group.GET("/", auth.AuthorizedTo(0), connection.GetUsers)
|
||||
group.GET("/@me", auth.AuthorizedTo(0), connection.GetUser)
|
||||
group.POST("/", auth.AuthorizedTo(models.Admin), connection.InviteUser)
|
||||
group.DELETE("/:user_id", auth.AuthorizedTo(models.Admin), connection.DeleteUser)
|
||||
group.PATCH("/:user_id/permissions", auth.AuthorizedTo(models.Admin), connection.SetUserPermissions)
|
||||
}
|
||||
|
Reference in New Issue
Block a user