/// <summary> /// Based on passed param, either use the authorisation code in UI to init a new org or /// check for a stored org cookie which would have originally been set up the same way. /// </summary> /// <param name="useNewAuthCode">When true, auth code control is used to init a new org.</param> private void InitOrganisation(bool useNewAuthCode) { // NOTE: Removed as it caused any security redirect to log off the user and they couldn't use Back button :-( //// Clear any current login so that there are no cross-org logins possible. //FormsAuthentication.SignOut(); //Roles.DeleteCookie(); //Cache[Globals.CacheKeys.ODS] = DateTime.Now.ToString(); OrganisationSettings settings = useNewAuthCode ? OrganisationSettings.Validate(_authorisationCode.Text) : new OrganisationSettings(); bool organisationIsValid = (null != settings && settings.IsValid); ToggleControlVisibility(organisationIsValid); // Clear the auth code textbox once the value has been validated or not found. _authorisationCode.Text = string.Empty; _organisationName.Text = organisationIsValid ? settings.OrganisationName : string.Empty; _organisationUnique.IsValid = organisationIsValid; //Clear the dictionary if (useNewAuthCode) { Dictionary <string, List <string> > dictionary = new Dictionary <string, List <string> >(); Cache[Globals.CacheKeys.UserNameDictionaryCacheEntry] = dictionary; } this.MainForm.DefaultButton = organisationIsValid ? _loginButton.UniqueID : _updateButton.UniqueID; Control focusControl = organisationIsValid ? _userNameCombo as Control : _authorisationCode; focusControl.Focus(); }