Fix for checkProjectManager endpoint and test_check_if_project_manager
This commit is contained in:
parent
0017e9b9ef
commit
45761dadcb
3 changed files with 7 additions and 4 deletions
|
@ -212,8 +212,12 @@ func (gs *GState) AddUserToProjectHandler(c *fiber.Ctx) error {
|
||||||
|
|
||||||
// IsProjectManagerHandler is a handler that checks if a user is a project manager for a given project
|
// IsProjectManagerHandler is a handler that checks if a user is a project manager for a given project
|
||||||
func (gs *GState) IsProjectManagerHandler(c *fiber.Ctx) error {
|
func (gs *GState) IsProjectManagerHandler(c *fiber.Ctx) error {
|
||||||
|
// Get the username from the token
|
||||||
|
user := c.Locals("user").(*jwt.Token)
|
||||||
|
claims := user.Claims.(jwt.MapClaims)
|
||||||
|
username := claims["name"].(string)
|
||||||
|
|
||||||
// Extract necessary parameters from the request query string
|
// Extract necessary parameters from the request query string
|
||||||
username := c.Query("username")
|
|
||||||
projectName := c.Query("projectName")
|
projectName := c.Query("projectName")
|
||||||
|
|
||||||
// Check if the user is a project manager for the specified project
|
// Check if the user is a project manager for the specified project
|
||||||
|
|
|
@ -98,7 +98,7 @@ func main() {
|
||||||
server.Post("/api/promoteToAdmin", gs.PromoteToAdmin)
|
server.Post("/api/promoteToAdmin", gs.PromoteToAdmin)
|
||||||
server.Get("/api/users/all", gs.ListAllUsers)
|
server.Get("/api/users/all", gs.ListAllUsers)
|
||||||
server.Get("/api/getWeeklyReportsUser/:projectName", gs.GetWeeklyReportsUserHandler)
|
server.Get("/api/getWeeklyReportsUser/:projectName", gs.GetWeeklyReportsUserHandler)
|
||||||
server.Get("api/checkIfProjectManager", gs.IsProjectManagerHandler)
|
server.Get("/api/checkIfProjectManager/:projectName", gs.IsProjectManagerHandler)
|
||||||
server.Post("/api/ProjectRoleChange", gs.ProjectRoleChange)
|
server.Post("/api/ProjectRoleChange", gs.ProjectRoleChange)
|
||||||
server.Get("/api/getUsersProject/:projectName", gs.ListAllUsersProject)
|
server.Get("/api/getUsersProject/:projectName", gs.ListAllUsersProject)
|
||||||
|
|
||||||
|
|
|
@ -329,9 +329,8 @@ def test_check_if_project_manager():
|
||||||
|
|
||||||
# Check if the user is a project manager for the project
|
# Check if the user is a project manager for the project
|
||||||
response = requests.get(
|
response = requests.get(
|
||||||
checkIfProjectManagerPath,
|
checkIfProjectManagerPath + "/" + projectName,
|
||||||
headers={"Authorization": "Bearer " + token},
|
headers={"Authorization": "Bearer " + token},
|
||||||
params={"username": username, "projectName": projectName},
|
|
||||||
)
|
)
|
||||||
|
|
||||||
dprint(response.text)
|
dprint(response.text)
|
||||||
|
|
Loading…
Reference in a new issue