Open Ledgers appears complete
This commit is contained in:
@@ -18,7 +18,7 @@ namespace Swarmops.Basic.Types.Security
|
||||
BasicPersonRole[] organizationPersonRoles,
|
||||
BasicPersonRole[] nodePersonRoles)
|
||||
{
|
||||
if (personId < 1)
|
||||
if (personId < -1)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException ("PersonId cannot be " + personId);
|
||||
}
|
||||
|
||||
+20
-1
@@ -594,7 +594,18 @@ namespace Swarmops.Logic.Swarm
|
||||
|
||||
public static Person FromIdentity (int personId)
|
||||
{
|
||||
return FromBasic (SwarmDb.GetDatabaseForReading().GetPerson (personId));
|
||||
if (personId > 0)
|
||||
{
|
||||
return FromBasic (SwarmDb.GetDatabaseForReading().GetPerson (personId));
|
||||
}
|
||||
else if (personId == Person.OpenLedgersIdentity)
|
||||
{
|
||||
return
|
||||
FromBasic (new BasicPerson (personId, string.Empty, "Open Ledgers", string.Empty, string.Empty,
|
||||
string.Empty, string.Empty, 0, string.Empty, 0, DateTime.MinValue, PersonGender.Unknown));
|
||||
}
|
||||
|
||||
throw new ArgumentException("No such PersonId: " + personId);
|
||||
}
|
||||
|
||||
public static Person FromIdentityAggressive (int personId)
|
||||
@@ -1117,6 +1128,14 @@ namespace Swarmops.Logic.Swarm
|
||||
return true;
|
||||
}
|
||||
|
||||
// if Open Ledgers
|
||||
|
||||
if ((access.Aspect == AccessAspect.Bookkeeping || access.Aspect == AccessAspect.Financials) &&
|
||||
access.Type == AccessType.Read && this.Identity == Person.OpenLedgersIdentity)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (access.Type == AccessType.Write)
|
||||
{
|
||||
ids = access.Organization.Parameters.TemporaryAccessListWrite;
|
||||
|
||||
@@ -96,7 +96,7 @@ public class PageV5Base : Page
|
||||
{
|
||||
// Check that the page has security defined
|
||||
|
||||
if (this.PageAccessRequired == null)
|
||||
if (this.PageAccessRequired == null && !this.GetType().FullName.ToLowerInvariant().Contains ("accessdenied"))
|
||||
{
|
||||
throw new SecurityException("Page security is undefined at " + this.GetType().FullName + ". This is not permitted: minimum security must be defined for every page.");
|
||||
}
|
||||
|
||||
@@ -32,7 +32,14 @@ namespace Swarmops.Controls.Base
|
||||
|
||||
XmlSerializer serializer = new XmlSerializer (typeof (MainMenuItem[]));
|
||||
|
||||
using (TextReader reader = new StreamReader (Server.MapPath ("~/MainMenu-v5.xml")))
|
||||
string mainMenuFile = "~/MainMenu-v5.xml";
|
||||
|
||||
if (CurrentUser.Identity == Person.OpenLedgersIdentity)
|
||||
{
|
||||
mainMenuFile = "~/MainMenu-v5-OpenLedgers.xml";
|
||||
}
|
||||
|
||||
using (TextReader reader = new StreamReader (Server.MapPath (mainMenuFile)))
|
||||
{
|
||||
MainMenuData = (MainMenuItem[]) serializer.Deserialize (reader);
|
||||
}
|
||||
@@ -90,9 +97,18 @@ namespace Swarmops.Controls.Base
|
||||
// TODO: More types here, and check with the CSS. Some work to get good looking
|
||||
|
||||
case MenuItemType.Link:
|
||||
output.Write (
|
||||
"<a href=\"{1}\"><img src=\"/Images/PageIcons/{0}-{3}.png\" height=\"20\" width=\"20\" />{2}</a>",
|
||||
menuItem.ImageUrl, prettyNavUrl, localizedText, iconSize);
|
||||
if (!string.IsNullOrEmpty (menuItem.ImageUrl))
|
||||
{
|
||||
output.Write (
|
||||
"<a href=\"{1}\"><img src=\"/Images/PageIcons/{0}-{3}.png\" height=\"20\" width=\"20\" />{2}</a>",
|
||||
menuItem.ImageUrl, prettyNavUrl, localizedText, iconSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
output.Write(
|
||||
"<a href=\"{0}\">{1}</a>",
|
||||
prettyNavUrl, localizedText);
|
||||
}
|
||||
break;
|
||||
case MenuItemType.Disabled:
|
||||
case MenuItemType.BuildNumber:
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ArrayOfMainMenuItem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
||||
|
||||
<!-- This file is maintained by hand. -->
|
||||
|
||||
<MainMenuItem>
|
||||
<ResourceKey>Ledgers_BalanceSheet</ResourceKey>
|
||||
<UserLevel>3</UserLevel>
|
||||
<Permissions />
|
||||
<ImageUrl />
|
||||
<NavigateUrl>/Pages/v5/Ledgers/BalanceSheet.aspx</NavigateUrl>
|
||||
<Type>Link</Type>
|
||||
<Children />
|
||||
</MainMenuItem>
|
||||
|
||||
<MainMenuItem>
|
||||
<ResourceKey>Ledgers_ProfitLossStatement</ResourceKey>
|
||||
<UserLevel>3</UserLevel>
|
||||
<Permissions />
|
||||
<ImageUrl />
|
||||
<NavigateUrl>/Pages/v5/Ledgers/ProfitLossStatement.aspx</NavigateUrl>
|
||||
<Type>Link</Type>
|
||||
<Children />
|
||||
</MainMenuItem>
|
||||
|
||||
<MainMenuItem>
|
||||
<ResourceKey>Ledgers_InspectLedgers</ResourceKey>
|
||||
<UserLevel>3</UserLevel>
|
||||
<Permissions />
|
||||
<ImageUrl />
|
||||
<NavigateUrl>/Pages/v5/Ledgers/InspectLedgers.aspx</NavigateUrl>
|
||||
<Type>Link</Type>
|
||||
<Children />
|
||||
</MainMenuItem>
|
||||
|
||||
|
||||
</ArrayOfMainMenuItem>
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using Swarmops.Logic.Security;
|
||||
|
||||
namespace Swarmops.Frontend.Pages.v5.User
|
||||
{
|
||||
@@ -15,6 +16,8 @@ namespace Swarmops.Frontend.Pages.v5.User
|
||||
Localize();
|
||||
}
|
||||
|
||||
PageAccessRequired = new Access (AccessAspect.Null, AccessType.Unknown);
|
||||
|
||||
PopulateRepeater();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Web;
|
||||
using Swarmops.Logic.Security;
|
||||
|
||||
namespace Swarmops.Frontend.Pages.v5.User
|
||||
{
|
||||
@@ -18,9 +19,10 @@ namespace Swarmops.Frontend.Pages.v5.User
|
||||
}
|
||||
|
||||
Response.SetCookie(new HttpCookie("PreferredCulture", cultureId));
|
||||
PageAccessRequired = new Access(AccessAspect.Null, AccessType.Unknown);
|
||||
|
||||
AuthenticationData authenticationData = GetAuthenticationDataAndCulture();
|
||||
if (authenticationData.CurrentUser != null)
|
||||
if (authenticationData.CurrentUser != null && authenticationData.CurrentUser.PersonId > 0)
|
||||
{
|
||||
authenticationData.CurrentUser.PreferredCulture = cultureId;
|
||||
}
|
||||
|
||||
@@ -87,12 +87,13 @@ namespace Swarmops.Pages.Security
|
||||
|
||||
// If we're on an Open Ledgers domain, autologin as Open Ledgers
|
||||
|
||||
Organization organization = Organization.FromOpenLedgersDomain(requestHost); // returns null if doesn't exist
|
||||
Organization organizationOpenLedgers = Organization.FromOpenLedgersDomain(requestHost); // returns null if doesn't exist
|
||||
|
||||
if (organization != null)
|
||||
if (organizationOpenLedgers != null)
|
||||
{
|
||||
Response.AppendCookie(new HttpCookie("DashboardMessage", HttpUtility.UrlEncode(Resources.Pages.Security.Login_AsOpenLedgers)));
|
||||
FormsAuthentication.SetAuthCookie(Person.OpenLedgersIdentity.ToString() + "," + organization.Identity.ToString(), true);
|
||||
Response.AppendCookie(new HttpCookie("DashboardMessage", HttpUtility.UrlEncode(String.Format(Resources.Pages.Security.Login_AsOpenLedgers, organizationOpenLedgers.Name))));
|
||||
FormsAuthentication.SetAuthCookie(Person.OpenLedgersIdentity.ToString() + "," + organizationOpenLedgers.Identity.ToString(), true);
|
||||
Response.Redirect ("/Ledgers/BalanceSheet");
|
||||
}
|
||||
|
||||
// Check for SSL and force it
|
||||
|
||||
Reference in New Issue
Block a user