private void Authenticate() { string password = Request.QueryString["p"]; string isPersistentString = Request.QueryString["cp"]; string loginName = this.LoginName; bool isPersistent = true; if (isPersistentString != null) { if (!Boolean.TryParse(isPersistentString, out isPersistent)) { isPersistent = false; } } Guid organizationId = this.OrganizationId; Guid instanceId = this.InstanceId; bool isCustomUrlEnabled = FrameworkConfiguration.Current.WebApplication.CustomUrl.Enabled; if (isCustomUrlEnabled) { if (organizationId == Guid.Empty) { string host = Request.Url.Host; if (!CustomUrlProvider.IsDefaultVanityUrl(host)) { CustomUrlProvider.ParseHost(host, ref organizationId, ref instanceId); } } else if (!GoogleProvider.IsGoogleProviderRequest(Request)) { this.VerifyVanityUrl(organizationId, instanceId); } } if (!(string.IsNullOrEmpty(loginName) || string.IsNullOrEmpty(password) || (organizationId == Guid.Empty))) { if (!isCustomUrlEnabled) { LoginProvider loginProvider = new LoginProvider(); loginProvider.SignOut(true, false); } try { LoginProvider.Current.Authenticate(loginName, Support.Decrypt(password), false, isPersistent, organizationId, instanceId); this.RedirectAfterLogOn(); } catch (AuthenticationException ex) { ShowErrorMessage(ex.Message); } } else { if (GoogleProvider.IsGoogleProviderRequest(Request)) { try { string accessToken = GoogleProvider.ProcessAuthorization(this.Context, ref organizationId, ref instanceId); string firstName = null; string lastName = null; GoogleProvider.GetUserProfile(accessToken, out loginName, out firstName, out lastName); } catch (AuthenticationException ex) { ShowErrorMessage(ex.Message); } if (!string.IsNullOrEmpty(loginName)) { m_EmailToLink = loginName; string message = null; try { string domain = GoogleProvider.GetDomain(Request); if (!string.IsNullOrEmpty(domain)) { EmailSuffixProvider.ParseEmailSuffixName(domain, ref organizationId, ref instanceId); } if (LoginProvider.Current.Authenticate(loginName, null, false, true, organizationId, instanceId)) { this.RedirectAfterLogOn(); } } catch (AuthenticationException ex) { message = ex.Message; } if (!string.IsNullOrEmpty(message)) { if (LoginProvider.Current.GetLogin(loginName) == null) { message = string.Format(CultureInfo.InvariantCulture, Resources.UserContext_ErrorMessage_YourAccountIsNotFound, loginName); } } if (!string.IsNullOrEmpty(message)) { this.ShowErrorMessage(message); this.EnableCustomHandling = false; } } } } }
protected void Page_Load(object sender, EventArgs e) { Micajah.Common.Pages.MasterPage.SetPageTitle(this.Page, ActionProvider.PagesAndControls.FindByActionId(ActionProvider.SignUpOrganizationPageActionId)); if (!this.Page.IsPostBack) { this.LoadResources(); ErrorPanel.Visible = false; if (GoogleProvider.IsGoogleProviderRequest(this.Request)) { string returnUrl = null; OAuth2Parameters parameters = null; try { GoogleProvider.ProcessAuthorization(this.Context, ref parameters, ref returnUrl); this.OAuth2Parameters = JsonConvert.SerializeObject(parameters); } catch (System.Security.Authentication.AuthenticationException ex) { ErrorContinueLink.NavigateUrl = returnUrl; ErrorLabel.Text = ex.Message; ErrorPanel.Visible = true; return; } string email = null; string firstName = null; string lastName = null; GoogleProvider.GetUserProfile(parameters.AccessToken, out email, out firstName, out lastName); if (!string.IsNullOrEmpty(email)) { Email.Text = email; Email.ReadOnly = true; } if (!string.IsNullOrEmpty(firstName)) { this.UserFirstName = firstName; } if (!string.IsNullOrEmpty(lastName)) { this.UserLastName = lastName; } } OrganizationUrlRow.Visible = FrameworkConfiguration.Current.WebApplication.CustomUrl.Enabled; OrganizationName.Focus(); Control captchaTextBoxLabel = Captcha.FindControl("CaptchaTextBoxLabel"); if (captchaTextBoxLabel != null) { captchaTextBoxLabel.Visible = false; } } ResourceProvider.RegisterValidatorScriptResource(this.Page); }