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
10 changes: 9 additions & 1 deletion Keas.Mvc/Controllers/Api/PeopleController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,22 @@ public async Task<IActionResult> Create([FromBody] Person person)
else
{
//Force lookup. Don't trust passed user
person.User = await _identityService.GetByKerberos(person.UserId);
user = await _identityService.GetByKerberos(person.UserId);
person.User = user;
}

if (person.User == null)
{
return NotFound();
}

//Need to have API call validated so it doesn't create a dup person
if(await _context.People.IgnoreQueryFilters().Where(a => a.TeamId == team.Id && a.UserId == user.Id).AnyAsync())
{
ModelState.AddModelError("UserId", "This user is already added to this team.");
return BadRequest(ModelState);
}

if (person.Supervisor != null)
{
_context.People.Attach(person.Supervisor);
Expand Down
5 changes: 3 additions & 2 deletions Keas.Mvc/Views/TeamAdmin/RegenerateApiCode.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
@if (Model.TeamApiCode != null)
{
<div class="card-content">
<p><b>Current API Code:</b></p>
<p>@Html.DisplayFor(model => model.TeamApiCode.ApiCode)</p>
<div><b>Current API Code:</b> @Html.DisplayFor(model => model.TeamApiCode.ApiCode)</div>
<div><b>Team Slug:</b> @Model.Slug</div>
<div><b>Team Id:</b> @Model.Id</div>
</div>
}
<div style="padding: 19px 20px 20px;">
Expand Down