Checkpoint commit on ledger inspection / auditin

This commit is contained in:
Rick Falkvinge
2015-02-25 16:03:41 +01:00
parent fa27e5222d
commit 0ee12463ef
10 changed files with 151 additions and 3 deletions
+10
View File
@@ -251,6 +251,16 @@ namespace Swarmops.Common.Enums
/// </summary>
OrgTemporaryAccessListRead,
/// <summary>
/// If defined, will autologin to read "open ledgers" when accessed through this domain
/// </summary>
OrgOpenLedgersDomain,
/// <summary>
/// If defined, will login to this organization when accessed through this domain (credentials still required)
/// </summary>
OrgVanityDomain,
/// <summary>
/// Free-text description of an inbound invoice (what's it for?)
/// </summary>
+38
View File
@@ -54,6 +54,42 @@ namespace Swarmops.Logic.Structure
return new Organization (basic);
}
public static Organization FromOpenLedgersDomain(string domain)
{
int[] organizationIds = SwarmDb.GetDatabaseForReading().GetObjectsByOptionalData(ObjectType.Organization, ObjectOptionalDataType.OrgOpenLedgersDomain, domain);
if (organizationIds.Length < 1)
{
return null;
}
else if (organizationIds.Length == 1)
{
return Organization.FromIdentity(organizationIds[0]);
}
else
{
throw new InvalidOperationException("Invalid state: multiple organizations with same open-ledgers domain");
}
}
public static Organization FromVanityDomain(string domain)
{
int[] organizationIds = SwarmDb.GetDatabaseForReading().GetObjectsByOptionalData(ObjectType.Organization, ObjectOptionalDataType.OrgVanityDomain, domain);
if (organizationIds.Length < 1)
{
return null;
}
else if (organizationIds.Length == 1)
{
return Organization.FromIdentity(organizationIds[0]);
}
else
{
throw new InvalidOperationException("Invalid state: multiple organizations with same vanity domain");
}
}
#endregion
private ObjectOptionalData _optionalData;
@@ -902,5 +938,7 @@ namespace Swarmops.Logic.Structure
return new DateTime (year, 12, 31, 23, 59, 59, 999);
}
}
}
+5
View File
@@ -1134,5 +1134,10 @@ namespace Swarmops.Logic.Swarm
return false;
}
// A couple of special cases
public const int OpenLedgersIdentity = -1;
}
}
@@ -601,4 +601,12 @@
<data name="TaxForms_Payroll_TotalTax" xml:space="preserve">
<value>Total Tax</value>
</data>
<data name="InspectLedgers_EditingTransactionX" xml:space="preserve">
<value>Viewing/Editing Transaction #&lt;span id="spanModalTransactionId"&gt;67890&lt;/span&gt;</value>
<comment>The transaction id is replaced client-side on display</comment>
</data>
<data name="InspectLedgers_InspectingTransactionX" xml:space="preserve">
<value>Inspecting Transaction #&lt;span id="spanModalTransactionId"&gt;12345&lt;/span&gt;</value>
<comment>The transaction id is replaced client-side on display</comment>
</data>
</root>
@@ -175,6 +175,10 @@
<data name="LockdownAccount_Ticket" xml:space="preserve">
<value>Lockdown Ticket</value>
</data>
<data name="Login_AsOpenLedgers" xml:space="preserve">
<value>&lt;strong&gt;OPEN LEDGERS&lt;/strong&gt;&lt;br/&gt;&lt;br/&gt;{0} is running Open Ledgers. This means that anybody may inspect the financial reports and bookkeeping. You have been logged on to the organization's Operations to do just that.</value>
<comment>The {0} is the organization name.</comment>
</data>
<data name="Login_BitIdEnabled" xml:space="preserve">
<value>&lt;strong&gt;BitId two-factor authentication is now enabled.&lt;/strong&gt;&lt;br/&gt;&lt;br/&gt;From now on, you can use your bitcoin wallet to log in (and will &lt;strong&gt;need&lt;/strong&gt; to do so). Thank you for enabling added security.&lt;br/&gt;&lt;br/&gt;Please remember to keep your phone secure with a password, too.</value>
</data>
+50 -1
View File
@@ -35,10 +35,12 @@
// Enable various actions on icon
$('img.LocalIconFlag').click(function () {
transactionId = $(this).attr("txId");
onFlagTransaction("Add Tx Id here");
});
$('img.LocalIconInspect').click(function () {
onInspectTransaction("Add Tx Id here");
transactionId = $(this).attr("txId");
onInspectTransaction(transactionId);
});
}
});
@@ -51,10 +53,23 @@
reloadData();
});
$("#IconCloseEdit").click(function () {
$('#divModalCover').fadeOut();
if (transactionDirty) {
$('#tableAccountPlan').treegrid('reload');
transactionDirty = false;
}
});
$('div.datagrid').css('opacity', 0.4);
});
var accountId = 0;
var transactionId = 0;
var transactionDirty = false;
function onAccountSelected(newAccountId) {
accountId = newAccountId;
@@ -75,6 +90,10 @@
}
function onInspectTransaction(transactionId) {
window.scrollTo(0, 0);
$('body').css('overflow-y', 'hidden');
$('#divModalCover').fadeIn();
alertify.log ('<asp:Label ID="LabelInspectNotAvailable" runat="server" />');
}
@@ -123,6 +142,36 @@
</tr>
</thead>
</table>
<div id="divModalCover" class="modalcover">
<div id="divModalBox" class="box modal">
<div class="content">
<div class="divIconCloseModal"><img id="IconCloseEdit" src="/Images/Icons/iconshock-cross-16px.png" /></div><h2><asp:Literal ID="LiteralEditHeader" runat="server"/></h2>
<table id="Table1" class="easyui-datagrid" style="width:100%;height:300px"
data-options="rownumbers:false,singleSelect:false,nowrap:false,fitColumns:true,fit:false,showFooter:false,loading:false,selectOnCheck:true,checkOnSelect:true,url:'Json-InspectLedgerData.aspx'"
idField="id">
<thead>
<tr>
<th data-options="field:'id',width:50,align:'right'"><asp:Label ID="Label1" runat="server" Text="ID#"/></th>
<th data-options="field:'datetime',width:90,sortable:true"><asp:Label ID="Label2" runat="server" Text="XYZ DateTime" /></th>
<th data-options="field:'description',width:270"><asp:Label ID="Label3" runat="server" Text="XYZ Description" /></th>
<th data-options="field:'deltaPos',width:70,align:'right'"><asp:Label ID="Label4" runat="server" Text="XYZ Debit" /></th>
<th data-options="field:'deltaNeg',width:70,align:'right'"><asp:Label ID="Label5" runat="server" Text="XYZ Credit" /></th>
<th data-options="field:'balance',width:80,align:'right'"><asp:Label ID="Label6" runat="server" Text="XYZ Balance" /></th>
</tr>
</thead>
</table>
<div id="DivModalFields" class="entryFields">
ModalFields
</div>
<div class="entryLabels">
entryLabels
</div>
</div>
</div>
</div>
</asp:Content>
@@ -70,6 +70,14 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
this.LabelFlagNotAvailable.Text = Resources.Pages.Ledgers.InspectLedgers_FlaggingNotAvailable;
this.LabelInspectNotAvailable.Text = Resources.Pages.Ledgers.InspectLedgers_InspectNotAvailable;
// if write access
this.LiteralEditHeader.Text = Resources.Pages.Ledgers.InspectLedgers_EditingTransactionX;
// else if read access
this.LiteralEditHeader.Text = Resources.Pages.Ledgers.InspectLedgers_InspectingTransactionX;
}
}
}
@@ -155,7 +155,7 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
runningBalance += row.AmountCents;
string actionHtml = String.Format (
"<img src=\"/Images/Icons/iconshock-magnifyingglass-16px.png\" class=\"LocalIconInspect\" baseid=\"\" />&nbsp;<img src=\"/Images/Icons/iconshock-flag-white-16px.png\" class=\"LocalIconFlag\" baseid=\"{0}\" />",
"<img src=\"/Images/Icons/iconshock-magnifyingglass-16px.png\" class=\"LocalIconInspect\" txId=\"{0}\" />&nbsp;<img src=\"/Images/Icons/iconshock-flag-white-16px.png\" class=\"LocalIconFlag\" txId=\"{0}\" />",
row.FinancialTransactionId.ToString (CultureInfo.InvariantCulture));
result.Append ("{" + String.Format (
+14 -1
View File
@@ -68,10 +68,13 @@ namespace Swarmops.Pages.Security
}
}
string requestHost = Request.Url.Host;
// If this is the Dev Sandbox, autologin
if (Request.Url.Host == "dev.swarmops.com" &&
if (requestHost == "dev.swarmops.com" &&
PilotInstallationIds.IsPilot (PilotInstallationIds.DevelopmentSandbox) &&
Request.QueryString["SuppressAutologin"] != "true")
{
@@ -82,6 +85,16 @@ namespace Swarmops.Pages.Security
Response.Redirect ("/");
}
// If we're on an Open Ledgers domain, autologin as Open Ledgers
Organization organization = Organization.FromOpenLedgersDomain(requestHost); // returns null if doesn't exist
if (organization != null)
{
Response.AppendCookie(new HttpCookie("DashboardMessage", HttpUtility.UrlEncode(Resources.Pages.Security.Login_AsOpenLedgers)));
FormsAuthentication.SetAuthCookie(Person.OpenLedgersIdentity.ToString() + "," + organization.Identity.ToString(), true);
}
// Check for SSL and force it
// Special case for CloudFlare deployments - there is a case where somebody will get their connections de-SSLed at the server
+13
View File
@@ -371,6 +371,19 @@ body.rtl .sidebar {
}
.divIconCloseModal {
float:right;
margin-top: 2px;
margin-right: -5px
}
body.rtl .divIconCloseModal {
float:left;
margin-top: 2px;
margin-left: -5px
}
/* LOGINBOX */