public async Task <IActionResult> DeleteUser(int userId) { if (!HttpContext.User.IsInRole("admin") && !_getAccessUser.UserCookieIs(HttpContext, Convert.ToString(userId))) { return(StatusCode(403, "Access Denied !")); } Result result = await _userGateway.DeleteUser(userId); if (result.ErrorMessage == "User not found") { return(BadRequest(result.ErrorMessage)); } // if the user delete his own account if (_getAccessUser.UserCookieIs(HttpContext, Convert.ToString(userId))) { await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); } return(Ok("User deleted")); }
public async Task <IActionResult> GetProjectByUserId(int userId) { if (userId == 0) { userId = Convert.ToInt32(HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier)); } if (!HttpContext.User.IsInRole("admin") && !_getAccessUser.UserCookieIs(HttpContext, Convert.ToString(userId))) { return(StatusCode(403, "Access Denied !")); } IEnumerable <ProjectUserIdData> result = await _projectGateway.GetProjectByUserId(userId); if (result == null) { return(BadRequest("User has not project")); } return(Ok(result)); }