Added a handler for getting all users for a specific project, WIP and untested
This commit is contained in:
parent
3515a86bbb
commit
a18ce465de
3 changed files with 17 additions and 1 deletions
|
@ -39,6 +39,7 @@ type GlobalState interface {
|
||||||
ListAllUsersProject(c *fiber.Ctx) error // To get a list of all users for a specific project
|
ListAllUsersProject(c *fiber.Ctx) error // To get a list of all users for a specific project
|
||||||
ProjectRoleChange(c *fiber.Ctx) error // To change a users role in a project
|
ProjectRoleChange(c *fiber.Ctx) error // To change a users role in a project
|
||||||
ChangeUserName(c *fiber.Ctx) error // WIP
|
ChangeUserName(c *fiber.Ctx) error // WIP
|
||||||
|
GetAllUsersProject(c *fiber.Ctx) error // WIP
|
||||||
}
|
}
|
||||||
|
|
||||||
// "Constructor"
|
// "Constructor"
|
||||||
|
|
|
@ -187,6 +187,20 @@ func (gs *GState) ListAllUsers(c *fiber.Ctx) error {
|
||||||
return c.JSON(users)
|
return c.JSON(users)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (gs *GState) GetAllUsersProject(c *fiber.Ctx) error {
|
||||||
|
// Get all users from a project
|
||||||
|
projectName := c.Params("projectName")
|
||||||
|
users, err := gs.Db.GetAllUsersProject(projectName)
|
||||||
|
if err != nil {
|
||||||
|
log.Info("Error getting users from project:", err) // Debug print
|
||||||
|
return c.Status(500).SendString(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Info("Returning all users")
|
||||||
|
// Return the list of users as JSON
|
||||||
|
return c.JSON(users)
|
||||||
|
}
|
||||||
|
|
||||||
// @Summary PromoteToAdmin
|
// @Summary PromoteToAdmin
|
||||||
// @Description promote chosen user to admin
|
// @Description promote chosen user to admin
|
||||||
// @Tags User
|
// @Tags User
|
||||||
|
|
|
@ -88,8 +88,9 @@ func main() {
|
||||||
server.Post("/api/loginrenew", gs.LoginRenew)
|
server.Post("/api/loginrenew", gs.LoginRenew)
|
||||||
server.Delete("/api/userdelete/:username", gs.UserDelete) // Perhaps just use POST to avoid headaches
|
server.Delete("/api/userdelete/:username", gs.UserDelete) // Perhaps just use POST to avoid headaches
|
||||||
server.Delete("api/project", gs.DeleteProject) // WIP
|
server.Delete("api/project", gs.DeleteProject) // WIP
|
||||||
server.Post("/api/project", gs.CreateProject)
|
server.Post("/api/project", gs.CreateProject) // WIP
|
||||||
server.Get("/api/project/:projectId", gs.GetProject)
|
server.Get("/api/project/:projectId", gs.GetProject)
|
||||||
|
server.Get("/api/project/getAllUsers", gs.GetAllUsersProject)
|
||||||
server.Get("/api/getWeeklyReport", gs.GetWeeklyReport)
|
server.Get("/api/getWeeklyReport", gs.GetWeeklyReport)
|
||||||
server.Post("/api/signReport", gs.SignReport)
|
server.Post("/api/signReport", gs.SignReport)
|
||||||
server.Put("/api/addUserToProject", gs.AddUserToProjectHandler)
|
server.Put("/api/addUserToProject", gs.AddUserToProjectHandler)
|
||||||
|
|
Loading…
Reference in a new issue