diff --git a/Site/Pages/v5/Public/Initialize.aspx.cs b/Site/Pages/v5/Public/Initialize.aspx.cs index 4f45ece5..3e59643c 100644 --- a/Site/Pages/v5/Public/Initialize.aspx.cs +++ b/Site/Pages/v5/Public/Initialize.aspx.cs @@ -747,8 +747,10 @@ namespace Swarmops.Frontend.Pages.v5.Public Person newPerson = Person.Create (name, mail, password, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, DateTime.MinValue, PersonGender.Unknown); - newPerson.AddParticipation (Organization.Sandbox, DateTime.MaxValue); - // Add membership in Sandbox + newPerson.AddParticipation(Organization.Sandbox, DateTime.MaxValue); + Authority firstAuthority = Authority.FromLogin(newPerson, Organization.Sandbox); + + FormsAuthentication.SetAuthCookie(firstAuthority.ToEncryptedXml(), true); // Initialize staffing to System and Sandbox with the new user @@ -775,32 +777,9 @@ namespace Swarmops.Frontend.Pages.v5.Public } } - // Protect against race condition on a really really slow server: wait until there is a first person or 15 seconds have expired + // We set an auth cookie earlier, so we should be able to just redirect - DateTime utcTimeout = DateTime.UtcNow.AddSeconds (15); - People people = People.GetAll(); - while (people.Count < 1 && DateTime.UtcNow < utcTimeout) - { - Thread.Sleep (500); - people = People.GetAll(); - } - - if (people.Count < 1) - { - throw new InvalidOperationException("First person has not been created despite 15-second timeout; cannot login"); - } - - // Get authenticated person - - Person expectedPersonOne = Authentication.Authenticate ("1", - this.TextFirstUserPassword1.Text); - - if (expectedPersonOne != null) - { - Authority firstAuthority = Authority.FromLogin(expectedPersonOne, Organization.Sandbox); - FormsAuthentication.RedirectFromLoginPage(firstAuthority.ToEncryptedXml(), true); - Response.Redirect ("/", true); - } + Response.Redirect ("/", true); }