diff --git a/Site5/Security/Login.aspx.cs b/Site5/Security/Login.aspx.cs index 1a459a78..67381757 100644 --- a/Site5/Security/Login.aspx.cs +++ b/Site5/Security/Login.aspx.cs @@ -262,8 +262,6 @@ namespace Swarmops.Pages.Security Person authenticatedPerson = Authentication.Authenticate (credentialsLogin, credentialsPass); - // TODO: Determine last logged-on organization. Right now, log on to Sandbox. - int lastOrgId = authenticatedPerson.LastLogonOrganizationId; if (PilotInstallationIds.IsPilot (PilotInstallationIds.PiratePartySE) && (lastOrgId == 3 || lastOrgId == 0)) @@ -276,7 +274,10 @@ namespace Swarmops.Pages.Security lastOrgId = Organization.SandboxIdentity; } - if (!authenticatedPerson.MemberOfWithInherited (lastOrgId)) + Authority testAuthority = Authority.FromLogin (authenticatedPerson, + Organization.FromIdentity (lastOrgId)); + + if (!authenticatedPerson.MemberOfWithInherited (lastOrgId) && !testAuthority.HasSystemAccess (AccessType.Read)) { // If the person doesn't have access to the last organization (anymore), log on to Sandbox // unless first pilot, in which case throw (deny login)