Persist org ID across sessions

This commit is contained in:
Rick Falkvinge
2014-12-21 03:08:59 +01:00
parent 88d2790665
commit 20e063acfb
9 changed files with 184 additions and 36 deletions
+6 -1
View File
@@ -284,6 +284,11 @@ namespace Swarmops.Basic.Enums
/// <summary>
/// For a person, the BitId address they use to login
/// </summary>
BitIdLoginAddress
BitIdLoginAddress,
/// <summary>
/// For a person, the last logged-on organization id. Used to go back there on new login.
/// </summary>
LastLoginOrganizationId
}
}
@@ -111,7 +111,7 @@ namespace Swarmops.Logic.App_GlobalResources {
}
/// <summary>
/// Looks up a localized string similar to [OrganizationName] Cash Advance Paid: [CurrencyCode] [BudgetAmountFloat].
/// Looks up a localized string similar to [[OrganizationName]] Cash Advance Paid: [CurrencyCode] [BudgetAmountFloat].
/// </summary>
internal static string CashAdvance_PaidOut_Subject {
get {
@@ -131,7 +131,7 @@ namespace Swarmops.Logic.App_GlobalResources {
}
/// <summary>
/// Looks up a localized string similar to (ACTION ITEM) [OrganizationName] Cash Advance Requested: [CurrencyCode] [BudgetAmountFloat] - Attestation Needed.
/// Looks up a localized string similar to [[OrganizationName] - ACTION ITEM] Cash Advance Requested: [CurrencyCode] [BudgetAmountFloat] - Attestation Needed.
/// </summary>
internal static string CashAdvance_Requested_Subject {
get {
@@ -149,7 +149,7 @@ namespace Swarmops.Logic.App_GlobalResources {
}
/// <summary>
/// Looks up a localized string similar to [OrganizationName] Expense Claim Attested: [CurrencyCode] [BudgetAmountFloat].
/// Looks up a localized string similar to [[OrganizationName]] Expense Claim Attested: [CurrencyCode] [BudgetAmountFloat].
/// </summary>
internal static string ExpenseClaim_Attested_Subject {
get {
@@ -169,7 +169,7 @@ namespace Swarmops.Logic.App_GlobalResources {
}
/// <summary>
/// Looks up a localized string similar to (ACTION ITEM) [OrganizationName] Expense Claim Created: [CurrencyCode] [BudgetAmountFloat] - Attestation Needed.
/// Looks up a localized string similar to [[OrganizationName] - ACTION ITEM] Expense Claim Created: [CurrencyCode] [BudgetAmountFloat] - Attestation Needed.
/// </summary>
internal static string ExpenseClaim_Created_Subject {
get {
@@ -189,7 +189,7 @@ namespace Swarmops.Logic.App_GlobalResources {
}
/// <summary>
/// Looks up a localized string similar to [OrganizationName] Expense Claim DE-attested: [CurrencyCode] [BudgetAmountFloat].
/// Looks up a localized string similar to [[OrganizationName]] Expense Claim DE-attested: [CurrencyCode] [BudgetAmountFloat].
/// </summary>
internal static string ExpenseClaim_Deattested_Subject {
get {
@@ -207,7 +207,7 @@ namespace Swarmops.Logic.App_GlobalResources {
}
/// <summary>
/// Looks up a localized string similar to [OrganizationName] Expense Claim DENIED: [CurrencyCode] [BudgetAmountFloat].
/// Looks up a localized string similar to [[OrganizationName]] Expense Claim DENIED: [CurrencyCode] [BudgetAmountFloat].
/// </summary>
internal static string ExpenseClaim_Denied_Subject {
get {
@@ -227,7 +227,7 @@ namespace Swarmops.Logic.App_GlobalResources {
}
/// <summary>
/// Looks up a localized string similar to [OrganizationName] Expense Claim Receipts DE-validated: [CurrencyCode] [BudgetAmountFloat].
/// Looks up a localized string similar to [[OrganizationName]] Expense Claim Receipts DE-validated: [CurrencyCode] [BudgetAmountFloat].
/// </summary>
internal static string ExpenseClaim_Devalidated_Subject {
get {
@@ -247,7 +247,7 @@ namespace Swarmops.Logic.App_GlobalResources {
}
/// <summary>
/// Looks up a localized string similar to [OrganizationName] Expense Claim Paid: [CurrencyCode] [BudgetAmountFloat].
/// Looks up a localized string similar to [[OrganizationName]] Expense Claim Paid: [CurrencyCode] [BudgetAmountFloat].
/// </summary>
internal static string ExpenseClaim_PaidOut_Subject {
get {
@@ -267,7 +267,7 @@ namespace Swarmops.Logic.App_GlobalResources {
}
/// <summary>
/// Looks up a localized string similar to [OrganizationName] Expense Claim Receipts Validated: [CurrencyCode] [BudgetAmountFloat].
/// Looks up a localized string similar to [[OrganizationName]] Expense Claim Receipts Validated: [CurrencyCode] [BudgetAmountFloat].
/// </summary>
internal static string ExpenseClaim_Validated_Subject {
get {
@@ -287,7 +287,7 @@ namespace Swarmops.Logic.App_GlobalResources {
}
/// <summary>
/// Looks up a localized string similar to (ACTION ITEM) [OrganizationName] Invoice Filed: [CurrencyCode] [BudgetAmountFloat] - Attestation Needed.
/// Looks up a localized string similar to [[OrganizationName] - ACTION ITEM] Invoice Filed: [CurrencyCode] [BudgetAmountFloat] - Attestation Needed.
/// </summary>
internal static string InboundInvoice_Created_Subject {
get {
@@ -295,6 +295,89 @@ namespace Swarmops.Logic.App_GlobalResources {
}
}
/// <summary>
/// Looks up a localized string similar to A new [Regular] was manually added to [OrganizationName] within an area of yours..
/// </summary>
internal static string Membership_New_Added_Body {
get {
return ResourceManager.GetString("Membership_New_Added_Body", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to [[OrganizationName]] New [Regular]: [PersonName], [PersonGeography] [CountryCode] (manual).
/// </summary>
internal static string Membership_New_Added_Subject {
get {
return ResourceManager.GetString("Membership_New_Added_Subject", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to A new [Regular] has signed up for [OrganizationName] within an area of yours..
/// </summary>
internal static string Membership_New_Selfsignup_Body {
get {
return ResourceManager.GetString("Membership_New_Selfsignup_Body", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to [[OrganizationName]] New [Regular]: [PersonName], [PersonGeography] [CountryCode].
/// </summary>
internal static string Membership_New_Selfsignup_Subject {
get {
return ResourceManager.GetString("Membership_New_Selfsignup_Subject", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to [[OrganizationName]] [Regularship] renewed: [PersonName], [PersonGeography] [CountryCode] (manual).
/// </summary>
internal static string Membership_Renewed_Manual_Subject {
get {
return ResourceManager.GetString("Membership_Renewed_Manual_Subject", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Your message has been queued for delivery and the recipients have been resolved. Your mail will be sent to, or be attempted to sent to, [RecipientCount] people in [Geography] in [OrganizationName]..
/// </summary>
internal static string OutboundComm_Resolved_Body {
get {
return ResourceManager.GetString("OutboundComm_Resolved_Body", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to [[OrganizationName]] Comm recipients determined for [GeographyName]: [RecipientCount].
/// </summary>
internal static string OutboundComm_Resolved_Subject {
get {
return ResourceManager.GetString("OutboundComm_Resolved_Subject", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Your message to [GeographyName] has been sent to all scheduled recipients. Of the [RecipientCount] planned recipients, [RecipientsSuccess] succeeded from Swarmops&apos; horizon. (These can fail later for a number of reasons, from broken computers to hospitalized recipients.)
///
///Time spent transmitting: [TransmissionTime]..
/// </summary>
internal static string OutboundComm_Sent_Body {
get {
return ResourceManager.GetString("OutboundComm_Sent_Body", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to [[OrganizationName]] Comms transmitted: [GeographyName].
/// </summary>
internal static string OutboundComm_Sent_Subject {
get {
return ResourceManager.GetString("OutboundComm_Sent_Subject", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Receipts have been filed that need validation for their financial processes to continue.
///
@@ -307,7 +390,7 @@ namespace Swarmops.Logic.App_GlobalResources {
}
/// <summary>
/// Looks up a localized string similar to (ACTION ITEM) [OrganizationName] Receipts Filed - Validation Needed.
/// Looks up a localized string similar to [[OrganizationName] - ACTION ITEM] Receipts Filed - Validation Needed.
/// </summary>
internal static string Receipts_Filed_Subject {
get {
@@ -137,7 +137,7 @@ Expect more communication from the budget owner to follow on the matter.</value>
This means you should see the amount on your account shortly.</value>
</data>
<data name="CashAdvance_PaidOut_Subject" xml:space="preserve">
<value>[OrganizationName] Cash Advance Paid: [CurrencyCode] [BudgetAmountFloat]</value>
<value>[[OrganizationName]] Cash Advance Paid: [CurrencyCode] [BudgetAmountFloat]</value>
</data>
<data name="CashAdvance_Requested_Body" xml:space="preserve">
<value>[ConcernedPersonName] has requested a cash advance of [CurrencyCode] [BudgetAmountFloat] for the purpose of [RequestPurpose]. This money is part of your budget, [BudgetName].
@@ -146,14 +146,14 @@ Please log on to Swarmops at [SystemUrl] to attest or deny.</value>
<comment>This is sent to the budget owner(s) only.</comment>
</data>
<data name="CashAdvance_Requested_Subject" xml:space="preserve">
<value>(ACTION ITEM) [OrganizationName] Cash Advance Requested: [CurrencyCode] [BudgetAmountFloat] - Attestation Needed</value>
<value>[[OrganizationName] - ACTION ITEM] Cash Advance Requested: [CurrencyCode] [BudgetAmountFloat] - Attestation Needed</value>
</data>
<data name="ExpenseClaim_Attested_Body" xml:space="preserve">
<value>Your expense claim with [OrganizationName] for [CurrencyCode] [BudgetAmountFloat], concerning [RequestPurpose], has been attested by the budget owner. It will be paid out to you when the receipts are confirmed valid.</value>
<comment>This is sent to the claimer.</comment>
</data>
<data name="ExpenseClaim_Attested_Subject" xml:space="preserve">
<value>[OrganizationName] Expense Claim Attested: [CurrencyCode] [BudgetAmountFloat]</value>
<value>[[OrganizationName]] Expense Claim Attested: [CurrencyCode] [BudgetAmountFloat]</value>
</data>
<data name="ExpenseClaim_Created_Body" xml:space="preserve">
<value>[ConcernedPersonName] has created an expense claim against the budget of [BudgetName] for the amount of [CurrencyCode] [BudgetAmountFloat]. The claim concerns [RequestPurpose]. You will need to attest this expense claim.
@@ -162,7 +162,7 @@ Please log on to Swarmops at [SystemUrl] to attest or deny.</value>
<comment>This is sent to the budget owner(s)only.</comment>
</data>
<data name="ExpenseClaim_Created_Subject" xml:space="preserve">
<value>(ACTION ITEM) [OrganizationName] Expense Claim Created: [CurrencyCode] [BudgetAmountFloat] - Attestation Needed</value>
<value>[[OrganizationName] - ACTION ITEM] Expense Claim Created: [CurrencyCode] [BudgetAmountFloat] - Attestation Needed</value>
<comment>ACTION ITEM should be translated.</comment>
</data>
<data name="ExpenseClaim_Deattested_Body" xml:space="preserve">
@@ -172,14 +172,14 @@ Expect more communication from the budget owner to follow on the matter.</value>
<comment>This is sent to the claimer.</comment>
</data>
<data name="ExpenseClaim_Deattested_Subject" xml:space="preserve">
<value>[OrganizationName] Expense Claim DE-attested: [CurrencyCode] [BudgetAmountFloat]</value>
<value>[[OrganizationName]] Expense Claim DE-attested: [CurrencyCode] [BudgetAmountFloat]</value>
</data>
<data name="ExpenseClaim_Denied_Body" xml:space="preserve">
<value>Your expense claim with [OrganizationName] for [CurrencyCode] [BudgetAmountFloat] concerning [RequestPurpose] has been denied. Expect more communications to follow on what you need to do to file a proper expense claim.</value>
<comment>This is sent to the claimer.</comment>
</data>
<data name="ExpenseClaim_Denied_Subject" xml:space="preserve">
<value>[OrganizationName] Expense Claim DENIED: [CurrencyCode] [BudgetAmountFloat]</value>
<value>[[OrganizationName]] Expense Claim DENIED: [CurrencyCode] [BudgetAmountFloat]</value>
</data>
<data name="ExpenseClaim_Devalidated_Body" xml:space="preserve">
<value>The receipts for your expense claim with [OrganizationName] for [CurrencyCode] [BudgetAmountFloat], concerning [RequestPurpose], have been DE-validated by the financial record keepers of the organization. This usually indicates some sort of problem with the documentation of your expense claim.
@@ -187,7 +187,7 @@ Expect more communication from the budget owner to follow on the matter.</value>
Expect more communication to follow on the matter. If you don't hear from record keepers in short time on this matter, do follow up with them.</value>
</data>
<data name="ExpenseClaim_Devalidated_Subject" xml:space="preserve">
<value>[OrganizationName] Expense Claim Receipts DE-validated: [CurrencyCode] [BudgetAmountFloat]</value>
<value>[[OrganizationName]] Expense Claim Receipts DE-validated: [CurrencyCode] [BudgetAmountFloat]</value>
</data>
<data name="ExpenseClaim_PaidOut_Body" xml:space="preserve">
<value>Your expense claim with [OrganizationName] for [CurrencyCode] [BudgetAmountFloat], concerning [RequestPurpose], has been marked as paid out by the organization's accountants.
@@ -195,7 +195,7 @@ Expect more communication to follow on the matter. If you don't hear from record
This means you should see the amount on your account shortly.</value>
</data>
<data name="ExpenseClaim_PaidOut_Subject" xml:space="preserve">
<value>[OrganizationName] Expense Claim Paid: [CurrencyCode] [BudgetAmountFloat]</value>
<value>[[OrganizationName]] Expense Claim Paid: [CurrencyCode] [BudgetAmountFloat]</value>
</data>
<data name="ExpenseClaim_Validated_Body" xml:space="preserve">
<value>The receipts for your expense claim with [OrganizationName] for [CurrencyCode] [BudgetAmountFloat], concerning [RequestPurpose], have been validated by people responsible for keeping the records in order.
@@ -204,7 +204,7 @@ The claim will be paid out to you when the amount has also been attested by the
<comment>This is sent to the claimer.</comment>
</data>
<data name="ExpenseClaim_Validated_Subject" xml:space="preserve">
<value>[OrganizationName] Expense Claim Receipts Validated: [CurrencyCode] [BudgetAmountFloat]</value>
<value>[[OrganizationName]] Expense Claim Receipts Validated: [CurrencyCode] [BudgetAmountFloat]</value>
</data>
<data name="InboundInvoice_Created_Body" xml:space="preserve">
<value>An invoice from [Supplier], concerning [Description], has been filed against your budget of [BudgetName] for the amount of [CurrencyCode] [BudgetAmountFloat]. You must attest this invoice before it proceeds to payout.
@@ -212,7 +212,36 @@ The claim will be paid out to you when the amount has also been attested by the
Please log on to Swarmops at [SystemUrl] to attest or deny.</value>
</data>
<data name="InboundInvoice_Created_Subject" xml:space="preserve">
<value>(ACTION ITEM) [OrganizationName] Invoice Filed: [CurrencyCode] [BudgetAmountFloat] - Attestation Needed</value>
<value>[[OrganizationName] - ACTION ITEM] Invoice Filed: [CurrencyCode] [BudgetAmountFloat] - Attestation Needed</value>
</data>
<data name="Membership_New_Added_Body" xml:space="preserve">
<value>A new [Regular] was manually added to [OrganizationName] within an area of yours.</value>
</data>
<data name="Membership_New_Added_Subject" xml:space="preserve">
<value>[[OrganizationName]] New [Regular]: [PersonName], [PersonGeography] [CountryCode] (manual)</value>
</data>
<data name="Membership_New_Selfsignup_Body" xml:space="preserve">
<value>A new [Regular] has signed up for [OrganizationName] within an area of yours.</value>
</data>
<data name="Membership_New_Selfsignup_Subject" xml:space="preserve">
<value>[[OrganizationName]] New [Regular]: [PersonName], [PersonGeography] [CountryCode]</value>
</data>
<data name="Membership_Renewed_Manual_Subject" xml:space="preserve">
<value>[[OrganizationName]] [Regularship] renewed: [PersonName], [PersonGeography] [CountryCode] (manual)</value>
</data>
<data name="OutboundComm_Resolved_Body" xml:space="preserve">
<value>Your message has been queued for delivery and the recipients have been resolved. Your mail will be sent to, or be attempted to sent to, [RecipientCount] people in [Geography] in [OrganizationName].</value>
</data>
<data name="OutboundComm_Resolved_Subject" xml:space="preserve">
<value>[[OrganizationName]] Comm recipients determined for [GeographyName]: [RecipientCount]</value>
</data>
<data name="OutboundComm_Sent_Body" xml:space="preserve">
<value>Your message to [GeographyName] has been sent to all scheduled recipients. Of the [RecipientCount] planned recipients, [RecipientsSuccess] succeeded from Swarmops' horizon. (These can fail later for a number of reasons, from broken computers to hospitalized recipients.)
Time spent transmitting: [TransmissionTime].</value>
</data>
<data name="OutboundComm_Sent_Subject" xml:space="preserve">
<value>[[OrganizationName]] Comms transmitted: [GeographyName]</value>
</data>
<data name="Receipts_Filed_Body" xml:space="preserve">
<value>Receipts have been filed that need validation for their financial processes to continue.
@@ -220,7 +249,7 @@ Please log on to Swarmops at [SystemUrl] to attest or deny.</value>
Please log on to Swarmops at [SystemUrl] to confirm or reject them.</value>
</data>
<data name="Receipts_Filed_Subject" xml:space="preserve">
<value>(ACTION ITEM) [OrganizationName] Receipts Filed - Validation Needed</value>
<value>[[OrganizationName] - ACTION ITEM] Receipts Filed - Validation Needed</value>
</data>
<data name="System_DatabaseSchemaUpgraded_Body" xml:space="preserve">
<value>Swarmops Backend [SwarmopsVersion] on host [HostName] has successfully upgraded the Swarmops database schema to revision [DbVersion].
+6
View File
@@ -430,6 +430,12 @@ namespace Swarmops.Logic.Swarm
}
}
public int LastLogonOrganizationId
{
get { return OptionalData.GetOptionalDataInt (ObjectOptionalDataType.LastLoginOrganizationId); }
set { OptionalData.SetOptionalDataInt (ObjectOptionalDataType.LastLoginOrganizationId, value); }
}
public string PortraitPhotographer
{
get { return OptionalData.GetOptionalDataString (ObjectOptionalDataType.PortraitPhotographer); }
+1 -1
View File
@@ -486,7 +486,7 @@
</div>
<div class="mainbar">
<div id="page-icon-encaps"><asp:Image ID="IconPage" runat="server" ImageUrl="~/Images/PageIcons/iconshock-ignitionkey-40px.png" /></div><h1><asp:Label ID="LabelPageTitle" Text="Installation" runat="server" /></h1>
<!--<div id="page-icon-encaps"><asp:Image ID="IconPage" runat="server" ImageUrl="~/Images/PageIcons/iconshock-ignitionkey-40px.png" /></div><h1><asp:Label ID="LabelPageTitle" Text="Installation" runat="server" /></h1>-->
<div class="box">
<div class="content">
@@ -48,6 +48,8 @@ namespace Swarmops.Frontend.Pages.v5.Security
suggestedOrganization.Identity.ToString (CultureInfo.InvariantCulture) + ",," +
logonFlags;
CurrentUser.LastLogonOrganizationId = suggestedOrganization.Identity;
if (!string.IsNullOrEmpty (returnUrlString))
{
FormsAuthentication.SetAuthCookie (userIdentityString, true);
+8 -6
View File
@@ -83,13 +83,15 @@
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
if (msg.d) {
// alert("<asp:Literal ID="LiteralLoginSuccess" runat="server" />"); // Modal on Chrome, so need a shaded div instead
if (msg.d == "Success") {
// Good credentials. TODO: Add manual 2FA challenge if applicable.
$('#TextLogin, #TextPass').css('background-image', "url('/Security/Images/iconshock-greentick-16px.png')").css('background-position', 'right center').css('background-repeat', 'no-repeat');
} else {
// inform user of bad credentials by means of a red cross on _both_ boxes
$('#TextLogin, #TextPass').css('background-image', "url('/Security/Images/iconshock-cross-12px.png')").css('background-position', 'right center').css('background-repeat', 'no-repeat');
}
} else if (msg.d == "Fail") {
// inform user of bad credentials by means of a red cross on _both_ boxes
$('#TextLogin, #TextPass').css('background-image', "url('/Security/Images/iconshock-cross-12px.png')").css('background-position', 'right center').css('background-repeat', 'no-repeat');
} else {
// wut?
}
},
error: function(msg) {
// retry after a second
+21 -6
View File
@@ -12,6 +12,7 @@ using Resources;
using Swarmops.Database;
using Swarmops.Logic.Cache;
using Swarmops.Logic.Security;
using Swarmops.Logic.Structure;
using Swarmops.Logic.Support;
using Swarmops.Logic.Swarm;
@@ -234,7 +235,7 @@ namespace Swarmops.Pages.Security
[WebMethod]
// ReSharper disable once InconsistentNaming
public static bool TestCredentials (string credentialsLogin, string credentialsPass, string credentials2FA,
public static string TestCredentials (string credentialsLogin, string credentialsPass, string credentials2FA,
string logonUriEncoded)
{
if (!string.IsNullOrEmpty (credentialsLogin.Trim()) && !string.IsNullOrEmpty (credentialsPass.Trim()))
@@ -248,17 +249,32 @@ namespace Swarmops.Pages.Security
// TODO: Determine last logged-on organization. Right now, log on to Sandbox.
int lastOrgId = authenticatedPerson.LastLogonOrganizationId;
if (lastOrgId == 0)
{
lastOrgId = Organization.SandboxIdentity;
}
if (!authenticatedPerson.MemberOfWithInherited (lastOrgId))
{
// If the person doesn't have access to the last organization (anymore), log on to Sandbox
lastOrgId = 1;
}
GuidCache.Set (logonUri + "-LoggedOn",
authenticatedPerson.Identity.ToString (CultureInfo.InvariantCulture) + ",1,,AuthPlain");
return true;
authenticatedPerson.Identity.ToString (CultureInfo.InvariantCulture) + "," + lastOrgId.ToString(CultureInfo.InvariantCulture) + ",,AuthPlain");
return "Success"; // Prepare here for "2FARequired" return code
}
catch (UnauthorizedAccessException)
{
return false;
return "Fail";
}
}
return false;
return "Fail";
}
@@ -281,7 +297,6 @@ namespace Swarmops.Pages.Security
this.LiteralCredentialsUser.Text = Resources.Pages.Security.Login_Username;
this.LiteralCredentialsPass.Text = Resources.Pages.Security.Login_Password;
this.LiteralCredentials2FA.Text = Resources.Pages.Security.Login_GoogleAuthenticatorCode;
this.LiteralLoginSuccess.Text = Resources.Pages.Security.Login_LoggingIn;
}
+6
View File
@@ -358,6 +358,12 @@ div.loginbox
background-color: #E4ECFF;
}
input.InputManualCredentials {
border: solid 1px #A2BEFF;
padding: 2px;
}
span.loginalphabetasign
{
font-size: 24px;