示例#1
0
        /// <summary>
        /// Handles the Authenticate event of the LoginCtrl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Web.UI.WebControls.AuthenticateEventArgs"/> instance containing the event data.</param>
        void LoginCtrl_Authenticate(object sender, AuthenticateEventArgs e)
        {
            string appName = ((TextBox)LoginCtrl.FindControl("Application")).Text;
            AppDto dto     = AppContext.Current.GetApplicationDto(appName);

            // If application does not exists or is not activa, prevent login
            if (dto == null || dto.Application.Count == 0 || !dto.Application[0].IsActive)
            {
                LogManager.WriteLog("LOGIN", LoginCtrl.UserName, "login.aspx", "Commerce Manager", "SYSTEM", "Application name is incorrect.", false);
                LoginCtrl.FailureText = "Login failed. Please try again.";
                return;
            }

            Membership.Provider.ApplicationName = appName;

            if (Membership.ValidateUser(LoginCtrl.UserName, LoginCtrl.Password))
            {
                CHelper.CreateAuthenticationCookie(LoginCtrl.UserName, appName, LoginCtrl.RememberMeSet);
                string url = FormsAuthentication.GetRedirectUrl(LoginCtrl.UserName, LoginCtrl.RememberMeSet);
                LogManager.WriteLog("LOGIN", LoginCtrl.UserName, "login.aspx", "Commerce Manager", "SYSTEM", String.Empty, true);
                if (url.Contains(".axd") || url.Contains("/Apps/Core/Controls/Uploader/")) // prevent redirecting to report files
                {
                    Response.Redirect("~/default.aspx");
                }
                else
                {
                    Response.Redirect(url);
                }
            }
            else
            {
                LogManager.WriteLog("LOGIN", LoginCtrl.UserName, "login.aspx", "Commerce Manager", "SYSTEM", "Login or password are incorrect.", false);
                LoginCtrl.FailureText = "Login failed. Please try again.";
            }
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            _signInManager          = Request.GetOwinContext().Get <ApplicationSignInManager>();
            LoginCtrl.Authenticate += LoginCtrl_Authenticate;

            if (IsPostBack)
            {
                return;
            }
            LoginCtrl.FindControl("ApplicationRow").Visible = AppContext.Current.GetApplicationDto().Application.Count != 1;
            LoginCtrl.Focus();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.Header.DataBind();

            SignInManager           = Request.GetOwinContext().Get <ApplicationSignInManager <SiteUser> >();
            LoginCtrl.Authenticate += LoginCtrl_Authenticate;

            if (IsPostBack)
            {
                return;
            }
            LoginCtrl.FindControl("ApplicationRow").Visible = Mediachase.Commerce.Core.AppContext.Current.GetApplicationDto().Application.Count != 1;
            LoginCtrl.Focus();
        }
        protected void LoginCtrl_Authenticate(object sender, AuthenticateEventArgs e)
        {
            var userName = ((TextBox)LoginCtrl.FindControl("UserName")).Text;
            var password = ((TextBox)LoginCtrl.FindControl("Password")).Text;
            var remember = ((CheckBox)LoginCtrl.FindControl("RememberMe")).Checked;

            var validated = SignInManager.PasswordSignIn(userName, password, remember, false) == SignInStatus.Success;

            if (validated)
            {
                HandleLoginSuccess(userName, remember);
            }
            else
            {
                HandleLoginFailure(UserLoginFailureMessage);
            }
        }
示例#5
0
        private void PopulateControls()
        {
            if (siteSettings == null)
            {
                return;
            }
            if (siteSettings.DisableDbAuth)
            {
                this.Visible = false; return;
            }

            LoginCtrl.SetRedirectUrl = true;

            txtUserName   = (TextBox)this.LoginCtrl.FindControl("UserName");
            txtPassword   = (TextBox)this.LoginCtrl.FindControl("Password");
            chkRememberMe = (CheckBox)this.LoginCtrl.FindControl("RememberMe");
            lnkRecovery   = (HyperLink)this.LoginCtrl.FindControl("lnkPasswordRecovery");
            divCaptcha    = (Panel)LoginCtrl.FindControl("divCaptcha");
            captcha       = (Telerik.Web.UI.RadCaptcha)LoginCtrl.FindControl("captcha");
            btnLogin      = (Button)this.LoginCtrl.FindControl("Login");

            if (!siteSettings.RequireCaptchaOnLogin)
            {
                if (divCaptcha != null)
                {
                    divCaptcha.Visible = false;
                }
                if (captcha != null)
                {
                    captcha.Enabled = false;
                }
            }

            if (lnkRecovery.Visible)
            {
                lnkRecovery.Visible = ((siteSettings.AllowPasswordRetrieval || siteSettings.AllowPasswordReset) && (!siteSettings.UseLdapAuth ||
                                                                                                                    (siteSettings.UseLdapAuth && siteSettings.AllowDbFallbackWithLdap)));
                lnkRecovery.NavigateUrl = this.LoginCtrl.PasswordRecoveryUrl;
            }

            if (chkRememberMe.Visible)
            {
                chkRememberMe.Visible = siteSettings.AllowPersistentLogin;
            }
        }
示例#6
0
        private void PopulateControls()
        {
            if (siteSettings == null)
            {
                return;
            }
            if (siteSettings.DisableDbAuth)
            {
                this.Visible = false; return;
            }

            LoginCtrl.SetRedirectUrl = SetRedirectUrl;

            lblUserID     = (SiteLabel)this.LoginCtrl.FindControl("lblUserID");
            lblEmail      = (SiteLabel)this.LoginCtrl.FindControl("lblEmail");
            txtUserName   = (TextBox)this.LoginCtrl.FindControl("UserName");
            txtPassword   = (TextBox)this.LoginCtrl.FindControl("Password");
            chkRememberMe = (CheckBox)this.LoginCtrl.FindControl("RememberMe");
            btnLogin      = (mojoButton)this.LoginCtrl.FindControl("Login");
            lnkRecovery   = (HyperLink)this.LoginCtrl.FindControl("lnkPasswordRecovery");
            lnkExtraLink  = (HyperLink)this.LoginCtrl.FindControl("lnkRegisterExtraLink");

            if (WebConfigSettings.DisableAutoCompleteOnLogin)
            {
                txtUserName.AutoCompleteType = AutoCompleteType.Disabled;
                txtPassword.AutoCompleteType = AutoCompleteType.Disabled;
            }

            divCaptcha = (Panel)LoginCtrl.FindControl("divCaptcha");
            captcha    = (CaptchaControl)LoginCtrl.FindControl("captcha");
            if (!siteSettings.RequireCaptchaOnLogin)
            {
                if (divCaptcha != null)
                {
                    divCaptcha.Visible = false;
                }
                if (captcha != null)
                {
                    captcha.Captcha.Enabled = false;
                }
            }
            else
            {
                captcha.ProviderName        = siteSettings.CaptchaProvider;
                captcha.RecaptchaPrivateKey = siteSettings.RecaptchaPrivateKey;
                captcha.RecaptchaPublicKey  = siteSettings.RecaptchaPublicKey;
            }

            if ((siteSettings.UseEmailForLogin) && (!siteSettings.UseLdapAuth))
            {
                if (!WebConfigSettings.AllowLoginWithUsernameWhenSiteSettingIsUseEmailForLogin)
                {
                    EmailValidator regexEmail = new EmailValidator();
                    regexEmail.ControlToValidate = txtUserName.ID;
                    regexEmail.ErrorMessage      = Resource.LoginFailedInvalidEmailFormatMessage;
                    this.LoginCtrl.Controls.Add(regexEmail);
                }
            }

            if (siteSettings.UseEmailForLogin && !siteSettings.UseLdapAuth)
            {
                this.lblUserID.Visible = false;
            }
            else
            {
                this.lblEmail.Visible = false;
            }

            if (SetFocus)
            {
                txtUserName.Focus();
            }

            lnkRecovery.Visible = ((siteSettings.AllowPasswordRetrieval || siteSettings.AllowPasswordReset) && (!siteSettings.UseLdapAuth ||
                                                                                                                (siteSettings.UseLdapAuth && siteSettings.AllowDbFallbackWithLdap)));

            lnkRecovery.NavigateUrl = this.LoginCtrl.PasswordRecoveryUrl;
            lnkRecovery.Text        = this.LoginCtrl.PasswordRecoveryText;

            lnkExtraLink.NavigateUrl = siteRoot + "/Secure/Register.aspx";
            lnkExtraLink.Text        = Resource.RegisterLink;
            lnkExtraLink.Visible     = siteSettings.AllowNewRegistration;

            string returnUrlParam = Page.Request.Params.Get("returnurl");

            if (!String.IsNullOrEmpty(returnUrlParam))
            {
                //string redirectUrl = returnUrlParam;
                lnkExtraLink.NavigateUrl += "?returnurl=" + SecurityHelper.RemoveMarkup(returnUrlParam);
            }

            chkRememberMe.Visible = siteSettings.AllowPersistentLogin;
            chkRememberMe.Text    = this.LoginCtrl.RememberMeText;

            if (WebConfigSettings.ForcePersistentAuthCheckboxChecked)
            {
                chkRememberMe.Checked = true;
                chkRememberMe.Visible = false;
            }

            btnLogin.Text = this.LoginCtrl.LoginButtonText;
            //SiteUtils.SetButtonAccessKey(btnLogin, AccessKeys.LoginAccessKey);
        }
示例#7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string returnUrl = HttpUtility.UrlEncode(Request.QueryString["ReturnUrl"]);

        if (!String.IsNullOrWhiteSpace(returnUrl))
        {
            RegisterHyperLink.NavigateUrl += "?ReturnUrl=" + returnUrl;
        }
        if (ConfigurationManager.AppSettings["EnableCAFDExSSO"] == "true")
        {
            if (Request.Cookies["CAFDExSSO"] != null)
            {
                //LogUtility.LogInfo("checking if membership user is logged in and authenticated");
                string CAFDExUserName = Request.Cookies["CAFDExSSO"].Value;
                if (ConfigurationManager.AppSettings["TestCAFDExSSO"] == "true")
                {
                    CAFDExUserName = string.IsNullOrEmpty(CAFDExUserName) ? "DERIK.J.HARRIS" : CAFDExUserName;
                }
                string reformattedUserName = "";
                if (!string.IsNullOrEmpty(CAFDExUserName))
                {
                    string[] sUserName = CAFDExUserName.Split('.');
                    if (sUserName.Length == 3)
                    {
                        reformattedUserName = sUserName[0] + "." + sUserName[2];
                    }
                    else
                    {
                        reformattedUserName = CAFDExUserName;
                    }
                }
                MembershipUser mu = Membership.GetUser(reformattedUserName);

                if (mu != null)
                {
                    FormsAuthentication.SetAuthCookie(mu.UserName, false);
                    Response.Redirect("~/Default.aspx");
                }
            }
        }

        RegisterHyperLink.NavigateUrl = "Register.aspx";

        if (User.Identity.IsAuthenticated == true)
        {
            Response.Redirect(returnUrl);
        }

        Page.Form.DefaultFocus = LoginCtrl.FindControl("UserName").ClientID;

        if (IsPostBack)
        {
            System.Threading.Thread.Sleep(1500);             //timeout needed to properly slide the menu bar

            var provider = Request.Form["provider"];
            if (provider == null)
            {
                return;
            }

            //var redirectUrl = "~/ExternalLoginLandingPage.aspx";
            var redirectUrl = "~/WTS_Login.aspx";
            if (!String.IsNullOrWhiteSpace(returnUrl))
            {
                var resolvedReturnUrl = ResolveUrl(returnUrl);                 //returnUrl;
                redirectUrl += "?ReturnUrl=" + HttpUtility.UrlEncode(resolvedReturnUrl);
            }

            OpenAuth.RequestAuthentication(provider, redirectUrl);
        }
    }
示例#8
0
        private void PopulateControls()
        {
            if (siteSettings == null)
            {
                return;
            }
            if (siteSettings.DisableDbAuth)
            {
                this.Visible = false; return;
            }

            LoginCtrl.SetRedirectUrl = setRedirectUrl;

            lblUserID     = (SiteLabel)this.LoginCtrl.FindControl("lblUserID");
            lblEmail      = (SiteLabel)this.LoginCtrl.FindControl("lblEmail");
            txtUserName   = (TextBox)this.LoginCtrl.FindControl("UserName");
            txtPassword   = (TextBox)this.LoginCtrl.FindControl("Password");
            chkRememberMe = (CheckBox)this.LoginCtrl.FindControl("RememberMe");
            btnLogin      = (Button)this.LoginCtrl.FindControl("Login");
            lnkRecovery   = (HyperLink)this.LoginCtrl.FindControl("lnkPasswordRecovery");
            lnkExtraLink  = (HyperLink)this.LoginCtrl.FindControl("lnkRegisterExtraLink");

            divCaptcha = (Panel)LoginCtrl.FindControl("divCaptcha");
            captcha    = (Telerik.Web.UI.RadCaptcha)LoginCtrl.FindControl("captcha");
            if (!siteSettings.RequireCaptchaOnLogin)
            {
                if (divCaptcha != null)
                {
                    divCaptcha.Visible = false;
                }
                if (captcha != null)
                {
                    captcha.Enabled = false;
                }
            }
            //else
            //{
            //    captcha.ProviderName = siteSettings.CaptchaProvider;
            //    captcha.RecaptchaPrivateKey = siteSettings.RecaptchaPrivateKey;
            //    captcha.RecaptchaPublicKey = siteSettings.RecaptchaPublicKey;
            //}

            // Remove 2015-01-06
            if ((siteSettings.UseEmailForLogin) && (!siteSettings.UseLdapAuth))
            {
                if (!WebConfigSettings.AllowLoginWithUsernameWhenSiteSettingIsUseEmailForLogin)
                {
                    RegularExpressionValidator regexEmail = new RegularExpressionValidator();
                    regexEmail.ControlToValidate = txtUserName.ID;
                    regexEmail.SetFocusOnError   = true;
                    //regexEmail.ValidationExpression = @"^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@(([0-9a-zA-Z])+([-\w]*[0-9a-zA-Z])*\.)+[a-zA-Z]{2,9})$";
                    regexEmail.ValidationExpression = SecurityHelper.RegexEmailValidationPattern;
                    regexEmail.ErrorMessage         = Resource.LoginFailedInvalidEmailFormatMessage;
                    regexEmail.ToolTip  = Resource.LoginFailedInvalidEmailFormatMessage;
                    regexEmail.Display  = ValidatorDisplay.Dynamic;
                    regexEmail.CssClass = "alert alert-danger";
                    regexEmail.SkinID   = "LoginValidator";
                    this.LoginCtrl.Controls.Add(regexEmail);
                }
            }

            if (siteSettings.UseEmailForLogin && !siteSettings.UseLdapAuth)
            {
                this.lblUserID.Visible = false;
                this.txtUserName.Attributes.Add("placeholder", Resource.SignInEmailLabel);

                lblEnterUsernamePassword.Text = string.Format(Resource.SignInEnterUsernamePasswordFormat, Resource.SignInEmailLabel);
            }
            else
            {
                this.lblEmail.Visible = false;
                this.txtUserName.Attributes.Add("placeholder", Resource.ManageUsersLoginNameLabel);

                lblEnterUsernamePassword.Text = string.Format(Resource.SignInEnterUsernamePasswordFormat, Resource.ManageUsersLoginNameLabel);
            }
            this.txtPassword.Attributes.Add("placeholder", Resource.SignInPasswordLabel);

            if (setFocus)
            {
                txtUserName.Focus();
            }

            lnkRecovery.Visible = ((siteSettings.AllowPasswordRetrieval || siteSettings.AllowPasswordReset) && (!siteSettings.UseLdapAuth ||
                                                                                                                (siteSettings.UseLdapAuth && siteSettings.AllowDbFallbackWithLdap)));

            lnkRecovery.NavigateUrl = this.LoginCtrl.PasswordRecoveryUrl;
            lnkRecovery.Text        = this.LoginCtrl.PasswordRecoveryText;

            lnkExtraLink.NavigateUrl = siteRoot + "/Secure/Register.aspx";
            if (lnkExtraLink.Text.Length == 0)
            {
                lnkExtraLink.Text = Resource.RegisterLink;
            }
            lnkExtraLink.Visible = siteSettings.AllowNewRegistration;

            string returnUrlParam = Page.Request.Params.Get("returnurl");

            if (!String.IsNullOrEmpty(returnUrlParam))
            {
                //string redirectUrl = returnUrlParam;
                lnkExtraLink.NavigateUrl += "?returnurl=" + returnUrlParam;
            }

            chkRememberMe.Visible = siteSettings.AllowPersistentLogin;
            if (chkRememberMe.Text.Length == 0)
            {
                chkRememberMe.Text = this.LoginCtrl.RememberMeText;
            }

            btnLogin.Text = this.LoginCtrl.LoginButtonText;
            SiteUtils.SetButtonAccessKey(btnLogin, AccessKeys.LoginAccessKey);
        }