From ab910cb59454be6a5c4b0fd7be03a6a09f5984f3 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Wed, 7 Mar 2018 21:09:18 +0100 Subject: [PATCH] Applicant should now be able to log in --- Logic/Swarm/Person.cs | 13 +++++++++++++ Site/App_GlobalResources/Pages.Public.designer.cs | 2 +- Site/App_GlobalResources/Pages.Public.resx | 2 +- Site/Pages/v5/Public/Signup.aspx.cs | 3 +-- Site/Security/Login.aspx.cs | 2 +- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Logic/Swarm/Person.cs b/Logic/Swarm/Person.cs index 1bb8a881..82f093fd 100644 --- a/Logic/Swarm/Person.cs +++ b/Logic/Swarm/Person.cs @@ -1076,6 +1076,19 @@ namespace Swarmops.Logic.Swarm return ParticipatesInOrganizationOrParent (org.Identity); } + + public bool ApplicantInOrganization(Organization org) + { + Applicants applicants = Applicants.FromArray(SwarmDb.GetDatabaseForReading().GetApplicants(this, org, DatabaseCondition.OpenTrue)); + if (applicants.Count > 0) + { + // There is at least one open application + return true; + } + + return false; + } + /* --- not used, commented out for usage of hardcoded org ids public int NationalPartyOrg (bool onlyIfMember) { diff --git a/Site/App_GlobalResources/Pages.Public.designer.cs b/Site/App_GlobalResources/Pages.Public.designer.cs index 168b3026..427022fe 100644 --- a/Site/App_GlobalResources/Pages.Public.designer.cs +++ b/Site/App_GlobalResources/Pages.Public.designer.cs @@ -180,7 +180,7 @@ namespace Resources.Pages { } /// - /// Looks up a localized string similar to This is the organization-specific text shown for Signup Finalization. It is set in Admin / Org Settings. When the new person presses Finish, they will be entered into the organization, logged on, and sent to the Dashboard as a Beginner user. + /// Looks up a localized string similar to This is the organization-specific text shown for Signup Finalization. It is set in Admin / Org Settings. When the new person presses Finish, they will be entered into the organization, logged on, and sent to the Dashboard as a Beginner user.. /// internal static string Signup_DefaultLastPageText { get { diff --git a/Site/App_GlobalResources/Pages.Public.resx b/Site/App_GlobalResources/Pages.Public.resx index 7d8c3fa6..88638fcc 100644 --- a/Site/App_GlobalResources/Pages.Public.resx +++ b/Site/App_GlobalResources/Pages.Public.resx @@ -163,7 +163,7 @@ If you volunteered for taking formal responsibility, somebody (probably also a v This is the organization's custom welcome text. It has not yet been written; it is set in Admin / Org Settings. - This is the organization-specific text shown for Signup Finalization. It is set in Admin / Org Settings. When the new person presses Finish, they will be entered into the organization, logged on, and sent to the Dashboard as a Beginner user + This is the organization-specific text shown for Signup Finalization. It is set in Admin / Org Settings. When the new person presses Finish, they will be entered into the organization, logged on, and sent to the Dashboard as a Beginner user. This is the organization's short sidebar info. It is set in Administration / Org Settings. diff --git a/Site/Pages/v5/Public/Signup.aspx.cs b/Site/Pages/v5/Public/Signup.aspx.cs index fa817420..6298c662 100644 --- a/Site/Pages/v5/Public/Signup.aspx.cs +++ b/Site/Pages/v5/Public/Signup.aspx.cs @@ -301,7 +301,6 @@ namespace Swarmops.Frontend.Pages.Public } - // TODO: CREATE APPLICATION INSTEAD DEPENDING ON POLICY // TODO: SEND NOTIFICATIONS @@ -336,7 +335,7 @@ namespace Swarmops.Frontend.Pages.Public // Set authentication cookie, which will log the new person in using the credentials just given - FormsAuthentication.SetAuthCookie (Authority.FromLogin (newPerson).ToEncryptedXml(), true); + FormsAuthentication.SetAuthCookie (Authority.FromLogin (newPerson, organization).ToEncryptedXml(), true); AjaxCallResult result = new AjaxCallResult {Success = true}; return result; diff --git a/Site/Security/Login.aspx.cs b/Site/Security/Login.aspx.cs index 75d0141a..242b0c2a 100644 --- a/Site/Security/Login.aspx.cs +++ b/Site/Security/Login.aspx.cs @@ -346,7 +346,7 @@ namespace Swarmops.Pages.Security Authority testAuthority = Authority.FromLogin (authenticatedPerson, Organization.FromIdentity (lastOrgId)); - if (!authenticatedPerson.ParticipatesInOrganizationOrParent (lastOrgId) && !testAuthority.HasSystemAccess (AccessType.Read)) + if (!authenticatedPerson.ParticipatesInOrganizationOrParent (lastOrgId) && !authenticatedPerson.ApplicantInOrganization (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)