Fix for checkProjectManager endpoint and test_check_if_project_manager

This commit is contained in:
Imbus 2024-03-20 17:50:51 +01:00
parent 0017e9b9ef
commit 45761dadcb
3 changed files with 7 additions and 4 deletions

View file

@ -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
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
username := c.Query("username")
projectName := c.Query("projectName")
// Check if the user is a project manager for the specified project

View file

@ -98,7 +98,7 @@ func main() {
server.Post("/api/promoteToAdmin", gs.PromoteToAdmin)
server.Get("/api/users/all", gs.ListAllUsers)
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.Get("/api/getUsersProject/:projectName", gs.ListAllUsersProject)

View file

@ -329,9 +329,8 @@ def test_check_if_project_manager():
# Check if the user is a project manager for the project
response = requests.get(
checkIfProjectManagerPath,
checkIfProjectManagerPath + "/" + projectName,
headers={"Authorization": "Bearer " + token},
params={"username": username, "projectName": projectName},
)
dprint(response.text)