public async Task <IActionResult> GetRequestById(int requestId) { RequestData requestResult = await _requestGateway.GetRequestById(requestId); if (requestResult == null) { return(BadRequest("Request not found")); } if (!HttpContext.User.IsInRole("admin")) { EnumProjectAccessRight projectAccessRight = await _getAccessUser.GetUserAccessRightProject(Convert.ToInt32(HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier)), requestResult.ProjectId); if (projectAccessRight == EnumProjectAccessRight.None) { ProjectIsPublic projectIsPublic = await _projectGateway.ProjectIsPublic(requestResult.ProjectId); if (projectIsPublic.IsPublic == 1) { return(StatusCode(403, "Access Denied !")); } } } return(Ok(requestResult)); }
private async Task <bool> UserCanReadProject(int projectId, ProjectData project) { EnumProjectAccessRight projectAccessRight = await _getAccessUser.GetUserAccessRightProject(Convert.ToInt32(HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier)), projectId); if (!HttpContext.User.IsInRole("admin") && projectAccessRight == EnumProjectAccessRight.None && project.IsPublic == 0) { return(false); } return(true); }
public async Task <IActionResult> GetUserInProject(int projectId) { EnumProjectAccessRight projectAccessRight = await _getAccessUser.GetUserAccessRightProject(Convert.ToInt32(HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier)), projectId); if (!HttpContext.User.IsInRole("admin") && projectAccessRight == EnumProjectAccessRight.None) { return(StatusCode(403, "Access Denied !")); } IEnumerable <UserInProjectData> result = await _projectGateway.GetUserInProject(projectId); if (result == null) { return(BadRequest("Project has no user")); } return(Ok(result)); }
public async Task <IActionResult> GetUserForInvitByProjectId(int projectId) { if (!HttpContext.User.IsInRole("admin")) { EnumProjectAccessRight accessRight = await _getAccessUser.GetUserAccessRightProject(Convert.ToInt32(HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier)), projectId); if (accessRight != EnumProjectAccessRight.Admin) { return(StatusCode(403, "Access Denied !")); } } IEnumerable <UserForInvitData> result = await _userGateway.GetUserForInvitByProjectId(projectId); if (result == null) { return(BadRequest("No user avaibles for invit")); } return(Ok(result)); }