diff --git a/Site5/Pages/v5/Security/SetCurrentOrganization.aspx.cs b/Site5/Pages/v5/Security/SetCurrentOrganization.aspx.cs
index 52911dcc..dccd0aa7 100644
--- a/Site5/Pages/v5/Security/SetCurrentOrganization.aspx.cs
+++ b/Site5/Pages/v5/Security/SetCurrentOrganization.aspx.cs
@@ -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);
diff --git a/Site5/Security/Login.aspx b/Site5/Security/Login.aspx
index c4890c07..08dbccf1 100644
--- a/Site5/Security/Login.aspx
+++ b/Site5/Security/Login.aspx
@@ -83,13 +83,15 @@
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
- if (msg.d) {
- // alert("
"); // 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
diff --git a/Site5/Security/Login.aspx.cs b/Site5/Security/Login.aspx.cs
index 660ba560..1cd811d1 100644
--- a/Site5/Security/Login.aspx.cs
+++ b/Site5/Security/Login.aspx.cs
@@ -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;
}
diff --git a/Site5/Style/style-v5.css b/Site5/Style/style-v5.css
index 30fa9d6b..d11aa10d 100644
--- a/Site5/Style/style-v5.css
+++ b/Site5/Style/style-v5.css
@@ -358,6 +358,12 @@ div.loginbox
background-color: #E4ECFF;
}
+
+input.InputManualCredentials {
+ border: solid 1px #A2BEFF;
+ padding: 2px;
+}
+
span.loginalphabetasign
{
font-size: 24px;