Commits (5)
......@@ -600,7 +600,7 @@ namespace Coscine.Api.Project.Controllers
return Unauthorized($"You are not an owner of the project.");
}
var invitations = _invitationModel.GetAllWhere(x => x.Project == projectId && x.Expiration > DateTime.UtcNow)
var invitations = _invitationModel.GetAllWhere(x => x.Project == projectId)
.Select(x => new InvitationReturnObject
{
Id = x.Id,
......@@ -652,11 +652,22 @@ namespace Coscine.Api.Project.Controllers
x.Expiration > DateTime.UtcNow
);
if (invitations != null && invitations.Any())
if (invitations.Any())
{
return BadRequest("This invitee already has a valid invitation to this project.");
}
var expiredInvitations = _invitationModel.GetAllWhere(
x => x.Project == sendInvitationObject.Project &&
x.InviteeEmail == sendInvitationObject.Email &&
x.Expiration <= DateTime.UtcNow
);
foreach (var expiredInvitation in expiredInvitations)
{
_invitationModel.Delete(expiredInvitation);
}
var token = _invitationModel.CreateInvitation(sendInvitationObject.Project, user.Id, sendInvitationObject.Role, sendInvitationObject.Email);
var body = new JObject
......
......@@ -5,7 +5,7 @@
<AssemblyName>Coscine.Api.Project</AssemblyName>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<TargetFramework>net5.0</TargetFramework>
<Version>2.2.5</Version>
<Version>2.3.0</Version>
</PropertyGroup>
<PropertyGroup>
<Authors>RWTH Aachen University</Authors>
......