Compare commits
No commits in common. "2409598c6e480b044bfd10969f2d31d67708a3bb" and "aa7c5de1fc6236a771bfc3b75f55960068e3e1c3" have entirely different histories.
2409598c6e
...
aa7c5de1fc
1 changed files with 0 additions and 45 deletions
|
@ -33,9 +33,6 @@ type GlobalState interface {
|
||||||
// SignCollection(c *fiber.Ctx) error // To sign a collection
|
// SignCollection(c *fiber.Ctx) error // To sign a collection
|
||||||
GetButtonCount(c *fiber.Ctx) error // For demonstration purposes
|
GetButtonCount(c *fiber.Ctx) error // For demonstration purposes
|
||||||
IncrementButtonCount(c *fiber.Ctx) error // For demonstration purposes
|
IncrementButtonCount(c *fiber.Ctx) error // For demonstration purposes
|
||||||
ListAllUsers(c *fiber.Ctx) error // To get a list of all users in the application database
|
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// "Constructor"
|
// "Constructor"
|
||||||
|
@ -183,45 +180,3 @@ func (gs *GState) GetUserProjects(c *fiber.Ctx) error {
|
||||||
// Return a json serialized list of projects
|
// Return a json serialized list of projects
|
||||||
return c.JSON(projects)
|
return c.JSON(projects)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListAllUsers is a handler that returns a list of all users in the application database
|
|
||||||
func (gs *GState) ListAllUsers(c *fiber.Ctx) error {
|
|
||||||
// Get all users from the database
|
|
||||||
users, err := gs.Db.GetAllUsersApplication()
|
|
||||||
if err != nil {
|
|
||||||
return c.Status(500).SendString(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return the list of users as JSON
|
|
||||||
return c.JSON(users)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (gs *GState) ListAllUsersProject(c *fiber.Ctx) error {
|
|
||||||
// Extract the project name from the request parameters or body
|
|
||||||
projectName := c.Params("projectName")
|
|
||||||
|
|
||||||
// Get all users associated with the project from the database
|
|
||||||
users, err := gs.Db.GetAllUsersProject(projectName)
|
|
||||||
if err != nil {
|
|
||||||
return c.Status(500).SendString(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return the list of users as JSON
|
|
||||||
return c.JSON(users)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ProjectRoleChange is a handler that changes a user's role within a project
|
|
||||||
func (gs *GState) ProjectRoleChange(c *fiber.Ctx) error {
|
|
||||||
// Extract the necessary parameters from the request
|
|
||||||
username := c.Params("username")
|
|
||||||
projectName := c.Params("projectName")
|
|
||||||
role := c.Params("role")
|
|
||||||
|
|
||||||
// Change the user's role within the project in the database
|
|
||||||
if err := gs.Db.ChangeUserRole(username, projectName, role); err != nil {
|
|
||||||
return c.Status(500).SendString(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return a success message
|
|
||||||
return c.SendStatus(fiber.StatusOK)
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue