Beispiel #1
0
        protected void Page_Init(object sender, EventArgs e)
        {
            HttpRequest request = base.Request;

            this.Page.EnableViewState = true;
            ipAddress = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
            SuspendedIPController objSuspendedIP = new SuspendedIPController();
            bool IsSuspended = objSuspendedIP.IsSuspendedIP(ipAddress);

            if (IsSuspended)
            {
                AlreadySuspendedIPAddress();
                MultiView1.Visible = false;
            }
        }
Beispiel #2
0
        private void LoginUser()
        {
            MembershipController  member         = new MembershipController();
            RoleController        role           = new RoleController();
            SuspendedIPController objSuspendedIP = new SuspendedIPController();

            //username = AESEncrytDecry.DecryptStringAES(HDusername.Value);
            password = AESEncrytDecry.DecryptStringAES(HDPassword.Value);
            if (password == "keyError")
            {
                FailureText.Text = string.Format("<span class='sfError'>{0}</span>", GetSageMessage("UserLogin", "UsernameandPasswordcombinationdoesntmatched"));//"Username and Password combination doesn't matched!";
            }
            else
            {
                UserInfo user = member.GetUserDetails(GetPortalID, UserName.Text);
                HttpContext.Current.Session[SessionKeys.IsLoginClick] = false;

                if (user.UserExists && user.IsApproved)
                {
                    if (!(string.IsNullOrEmpty(UserName.Text) && string.IsNullOrEmpty(password)))
                    {
                        if (PasswordHelper.ValidateUser(user.PasswordFormat, password, user.Password, user.PasswordSalt))
                        {
                            SucessFullLogin(user);
                        }
                        else
                        {
                            if (Session[SessionKeys.LoginHitCount] == null)
                            {
                                Session[SessionKeys.LoginHitCount] = 1;
                            }
                            else
                            {
                                loginhit = Convert.ToInt32(Session[SessionKeys.LoginHitCount]);
                                loginhit++;
                                Session[SessionKeys.LoginHitCount] = loginhit;
                            }
                            FailureText.Text  = string.Format("<span class='sfError'>{0}</span>", GetSageMessage("UserLogin", "UsernameandPasswordcombinationdoesntmatched"));//"Username and Password combination doesn't matched!";
                            CaptchaValue.Text = string.Empty;
                            if (loginhit == 3)
                            {
                                Page.Response.Redirect(Page.Request.Url.ToString(), true);
                            }
                            if (loginhit > 3 && loginhit < 6)
                            {
                                InitializeCaptcha();
                                CaptchaValue.Text = string.Empty;
                            }
                            else if (loginhit >= 6)
                            {
                                objSuspendedIP.SaveSuspendedIP(ipAddress);
                                SuspendedIPAddressException();
                                Session[SessionKeys.LoginHitCount] = 0;
                                MultiView1.Visible = false;
                            }
                        }
                    }
                }
                else
                {
                    if (Session[SessionKeys.LoginHitCount] == null)
                    {
                        Session[SessionKeys.LoginHitCount] = 1;
                    }
                    else
                    {
                        loginhit = Convert.ToInt32(Session[SessionKeys.LoginHitCount]);
                        loginhit++;
                        Session[SessionKeys.LoginHitCount] = loginhit;
                    }
                    FailureText.Text  = string.Format("<span class='sfError'>{0}</span>", GetSageMessage("UserLogin", "UserDoesnotExist"));
                    CaptchaValue.Text = string.Empty;
                    if (loginhit == 3)
                    {
                        Page.Response.Redirect(Page.Request.Url.ToString(), true);
                    }
                    if (loginhit > 3 && loginhit < 6)
                    {
                        InitializeCaptcha();
                        CaptchaValue.Text = string.Empty;
                    }
                    else if (loginhit >= 6)
                    {
                        objSuspendedIP.SaveSuspendedIP(ipAddress);
                        SuspendedIPAddressException();
                        Session[SessionKeys.LoginHitCount] = 0;
                        MultiView1.Visible = false;
                    }
                }
            }
        }