Exemple #1
0
        /// <summary>
        /// Occurs when the login button is clicked.
        /// </summary>
        /// <param name="sender">The sourceRow of the event.</param>
        /// <param name="e">An EventArgs that contains no event data.</param>
        protected void LogOnButton_Click(object sender, EventArgs e)
        {
            string loginName = LoginTextBox.Text;

            try
            {
                if (LoginProvider.Current.Authenticate(loginName, PasswordTextBox.Text, true, true, this.OrganizationId, this.InstanceId))
                {
                    if (!string.IsNullOrEmpty(m_EmailToLink))
                    {
                        if (!EmailProvider.IsEmailExists(m_EmailToLink))
                        {
                            LinkEmailLabel.Text = string.Format(CultureInfo.InvariantCulture, Resources.LogOnControl_LinkEmailLabel_Text, loginName, m_EmailToLink);

                            LinkEmailPanel.Visible = true;
                            FormTable.Visible      = false;
                            if (LogoImagePanel != null)
                            {
                                LogoImagePanel.Visible = false;
                            }

                            m_MainContainerHeight = 150;
                        }
                        else
                        {
                            this.RedirectAfterLogOn();
                        }
                    }
                    else
                    {
                        this.RedirectAfterLogOn();
                    }
                }
            }
            catch (AuthenticationException ex)
            {
                string message = ex.Message;

                if (FrameworkConfiguration.Current.WebApplication.Integration.Google.Enabled)
                {
                    IList domains = null;

                    if (string.Compare(ex.Message, FrameworkConfiguration.Current.WebApplication.Login.FailureText, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        Organization org = OrganizationProvider.GetOrganization(this.OrganizationId);

                        if (org == null)
                        {
                            OrganizationCollection orgs = LoginProvider.Current.GetOrganizationsByLoginName(loginName);
                            if ((orgs != null) && (orgs.Count > 0))
                            {
                                org = orgs[0];
                            }
                        }

                        if (org != null)
                        {
                            if (SettingProvider.OrganizationProviderIsGoogle(org.OrganizationId))
                            {
                                domains = EmailSuffixProvider.GetEmailSuffixesList(org.OrganizationId);
                            }
                        }
                    }

                    if (domains == null)
                    {
                        domains = FrameworkConfiguration.Current.WebApplication.Integration.Google.MailDomains;
                    }

                    if (domains != null)
                    {
                        foreach (string domain in domains)
                        {
                            if (loginName.IndexOf(domain, StringComparison.OrdinalIgnoreCase) != -1)
                            {
                                message = Resources.LoginElement_GoogleFailureText;
                                break;
                            }
                        }
                    }
                }

                this.ShowErrorMessage(message);
            }
        }