Commit 302af7a0 authored by Petar Hristov's avatar Petar Hristov 💬
Browse files

Merge branch 'Topic/1530-invitationUserManagement' into 'Product/1548-projectInviteMngmnt'

Fix: Naming and Json Property of Invitation Object (coscine/issues#1530)

See merge request !149
parents db7d88e5 c54b4453
......@@ -620,13 +620,13 @@ namespace Coscine.Api.Project.Controllers
/// <param name="sendInvitationObject">Informations for sending an invitation</param>
/// <returns>NoContent</returns>
[HttpPost("[controller]/invitation")]
public IActionResult SendInvitation(SendInvitationObject sendInvitationObject)
public IActionResult SendInvitation([FromBody] SendInvitationObject sendInvitationObject)
{
var user = _authenticator.GetUser();
if (!IsValidEmail(sendInvitationObject.Mail))
if (!IsValidEmail(sendInvitationObject.Email))
{
return BadRequest($@"The email ""{sendInvitationObject.Mail}"" is invalid.");
return BadRequest($@"The email ""{sendInvitationObject.Email}"" is invalid.");
}
var project = _projectModel.GetById(sendInvitationObject.Project);
......@@ -648,7 +648,7 @@ namespace Coscine.Api.Project.Controllers
var invitations = _invitationModel.GetAllWhere(
x => x.Project == sendInvitationObject.Project &&
x.InviteeEmail == sendInvitationObject.Mail &&
x.InviteeEmail == sendInvitationObject.Email &&
x.Expiration > DateTime.UtcNow
);
......@@ -657,7 +657,7 @@ namespace Coscine.Api.Project.Controllers
return BadRequest("This invitee already has a valid invitation to this project.");
}
var token = _invitationModel.CreateInvitation(sendInvitationObject.Project, user.Id, sendInvitationObject.Role, sendInvitationObject.Mail);
var token = _invitationModel.CreateInvitation(sendInvitationObject.Project, user.Id, sendInvitationObject.Role, sendInvitationObject.Email);
var body = new JObject
{
......@@ -670,7 +670,7 @@ namespace Coscine.Api.Project.Controllers
}
};
NotificationBusUtil.Send(Program.Configuration, "user_invitation", NotificationBusUtil.GetUserList(new User { EmailAddress = sendInvitationObject.Mail }), sendInvitationObject.Project.ToString(), body);
NotificationBusUtil.Send(Program.Configuration, "user_invitation", NotificationBusUtil.GetUserList(new User { EmailAddress = sendInvitationObject.Email }), sendInvitationObject.Project.ToString(), body);
return NoContent();
}
......
using System;
using Newtonsoft.Json;
namespace Coscine.Api.Project.ParameterObjects
{
......@@ -10,14 +11,17 @@ namespace Coscine.Api.Project.ParameterObjects
/// <summary>
/// Id of the project
/// </summary>
[JsonProperty("projectId")]
public Guid Project { get; set; }
/// <summary>
/// Id of the target role
/// </summary>
[JsonProperty("role")]
public Guid Role { get; set; }
/// <summary>
/// Email of the target user
/// </summary>
public string Mail { get; set; }
[JsonProperty("email")]
public string Email { get; set; }
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment