Enabling edit of personal data
This commit is contained in:
@@ -85,8 +85,6 @@ namespace Swarmops.Database
|
||||
|
||||
public int CreateSwarmopsLogEntry (int personId, string entryType, string entryXml)
|
||||
{
|
||||
DateTime now = DateTime.UtcNow;
|
||||
|
||||
using (DbConnection connection = GetMySqlDbConnection())
|
||||
{
|
||||
connection.Open();
|
||||
|
||||
@@ -193,6 +193,7 @@
|
||||
<Compile Include="Communications\Payload\PayloadEnvelope.cs" />
|
||||
<Compile Include="Communications\Payload\NotificationPayload.cs" />
|
||||
<Compile Include="Support\BlockchainTransaction.cs" />
|
||||
<Compile Include="Support\LogEntries\PersonalDataChangedLogEntry.cs" />
|
||||
<Compile Include="Support\PayloadBase.cs" />
|
||||
<Compile Include="Financial\BankDataReaders\SEPaymentsBankgiroReader.cs" />
|
||||
<Compile Include="Financial\Currencies.cs" />
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Swarmops.Logic.Support.LogEntries
|
||||
{
|
||||
[Serializable]
|
||||
public class PersonalDataChangedLogEntry: LogEntryBase<PersonalDataChangedLogEntry>
|
||||
{
|
||||
public int AffectedPersonId;
|
||||
public int ActingPersonId;
|
||||
public string IpAddress;
|
||||
public string OldValue;
|
||||
public string NewValue;
|
||||
public string Field; // freetext field: "Name", "Mail", and so on
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,8 @@ using System.Web.UI.WebControls;
|
||||
using Swarmops.Common.Enums;
|
||||
using Swarmops.Logic.Security;
|
||||
using Swarmops.Logic.Structure;
|
||||
using Swarmops.Logic.Support;
|
||||
using Swarmops.Logic.Support.LogEntries;
|
||||
using Swarmops.Logic.Swarm;
|
||||
using Swarmops.Common.Exceptions;
|
||||
using Swarmops.Frontend;
|
||||
@@ -284,12 +286,64 @@ namespace Swarmops.Frontend.Automation
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Verify authority to see and change personal data
|
||||
|
||||
Person affectedPerson = Person.FromIdentity (personId);
|
||||
|
||||
if (!self)
|
||||
{
|
||||
if (!authData.Authority.CanSeePerson (affectedPerson) ||
|
||||
!authData.Authority.HasAccess (new Access (authData.CurrentOrganization, affectedPerson.Geography,
|
||||
AccessAspect.PersonalData)))
|
||||
{
|
||||
throw new UnauthorizedAccessException();
|
||||
}
|
||||
}
|
||||
|
||||
string oldValue;
|
||||
|
||||
switch (field)
|
||||
{
|
||||
case "Name":
|
||||
oldValue = affectedPerson.Name;
|
||||
affectedPerson.Name = newValue;
|
||||
break;
|
||||
case "Mail":
|
||||
oldValue = affectedPerson.Mail;
|
||||
affectedPerson.Mail = newValue;
|
||||
break;
|
||||
case "Phone":
|
||||
oldValue = affectedPerson.Phone;
|
||||
affectedPerson.Phone = newValue;
|
||||
break;
|
||||
case "TwitterId":
|
||||
oldValue = affectedPerson.TwitterId;
|
||||
affectedPerson.TwitterId = newValue;
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentException("Unrecognized field in /Automation/SwarmFunctions.SetPersonEditorData");
|
||||
}
|
||||
|
||||
SwarmopsLogEntry logEntry = SwarmopsLog.CreateEntry (affectedPerson, new PersonalDataChangedLogEntry
|
||||
{
|
||||
ActingPersonId = authData.CurrentUser.PersonId,
|
||||
AffectedPersonId = affectedPerson.PersonId,
|
||||
Field = field,
|
||||
IpAddress = HttpContext.Current.Request.UserHostAddress,
|
||||
OldValue = oldValue,
|
||||
NewValue = newValue
|
||||
});
|
||||
|
||||
if (!self)
|
||||
{
|
||||
logEntry.CreateAffectedObject (authData.CurrentUser);
|
||||
}
|
||||
|
||||
return new AjaxInputCallResult
|
||||
{
|
||||
Success = true,
|
||||
NewValue = field + ": (Work in progress) call successful"
|
||||
NewValue = newValue
|
||||
};
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static string GetPersonValue (int personId, string field)
|
||||
|
||||
Reference in New Issue
Block a user