Handler ProjectRoleChange in global_state.go added for ChangeUserRole in db.go
This commit is contained in:
parent
f2a4c417aa
commit
2409598c6e
1 changed files with 17 additions and 0 deletions
|
@ -35,6 +35,7 @@ type GlobalState interface {
|
||||||
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
|
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
|
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"
|
||||||
|
@ -208,3 +209,19 @@ func (gs *GState) ListAllUsersProject(c *fiber.Ctx) error {
|
||||||
// Return the list of users as JSON
|
// Return the list of users as JSON
|
||||||
return c.JSON(users)
|
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