Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<label class="form-check-label" for="inlineRadio1">Public</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" formControlName="visibility" id="inlineRadio2" value="private" [readOnly]="isLoading" [disabled]="true">
<input class="form-check-input" type="radio" formControlName="visibility" id="inlineRadio2" value="private" [readOnly]="isLoading">
<label class="form-check-label" for="inlineRadio2">Private</label>
</div>
</div>
Expand Down Expand Up @@ -47,4 +47,3 @@
</div>
</form> <!-- Project Form End -->


Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class ProjectFormCreateComponent implements OnInit {
// Initialize Form Controls
this.name = new FormControl('', [Validators.required, Validators.minLength(5), Validators.maxLength(20), this.noSpaceSpecial()])
this.description = new FormControl('')
this.visibility = new FormControl('')
this.visibility = new FormControl('public', [Validators.required])

// Initialize FormGroup using FormBuilder
this.projectForm = this.formBuilder.group({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ <h4 class="card-title text-center mb-4 mt-1">Edit Project</h4>
<label class="form-check-label" for="inlineRadio1">Public</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" formControlName="visibility" id="inlineRadio2" value="private" [readOnly]="isLoading" [disabled]="true">
<input class="form-check-input" type="radio" formControlName="visibility" id="inlineRadio2" value="private" [readOnly]="isLoading">
<label class="form-check-label" for="inlineRadio2">Private</label>
</div>
</div>
Expand Down Expand Up @@ -47,4 +47,3 @@ <h4 class="card-title text-center mb-4 mt-1">Edit Project</h4>
</button>
</div>
</form> <!-- Project Form End -->

26 changes: 23 additions & 3 deletions src/Analysim.Web/Controllers/AccountController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1365,16 +1365,36 @@ public IActionResult GetProjects([FromRoute] int userID)
//var user = _dbContext.Users.SingleOrDefault(x => x.Id == userID);
//if (user == null) return NotFound(new { message = "User Not Found" });

var userProjects = _dbContext.ProjectUsers
var userProjectsQuery = _dbContext.ProjectUsers
.Include(pu => pu.Project)
.ThenInclude(p => p.BlobFiles)
.Include(pu => pu.Project)
.ThenInclude(p => p.ProjectUsers)
.Include(pu => pu.Project)
.ThenInclude(p => p.ProjectTags)
.ThenInclude(pt => pt.Tag)
.Where(pu => pu.UserID == userID)
.AsEnumerable();
.Where(pu => pu.UserID == userID);

if (!IsCurrentUserAdmin())
{
var currentUserIdClaim = User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
if (int.TryParse(currentUserIdClaim, out var currentUserId))
{
userProjectsQuery = userProjectsQuery.Where(pu =>
(pu.Project.Visibility != null && pu.Project.Visibility.ToLower() == "public") ||
pu.Project.ProjectUsers.Any(projectUser =>
projectUser.UserID == currentUserId &&
projectUser.UserRole != null &&
projectUser.UserRole.ToLower() != "follower"));
}
else
{
userProjectsQuery = userProjectsQuery.Where(pu =>
pu.Project.Visibility != null && pu.Project.Visibility.ToLower() == "public");
}
}

var userProjects = userProjectsQuery.ToList();


//if (userProjects.Count() == 0) return NoContent();
Expand Down
Loading
Loading