Ejemplo n.º 1
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnLogin_Click(object sender, ImageClickEventArgs e)
        {
            string verifyCode = CtrlHelper.GetText(txtVerifyCode);
            string accounts   = TextFilter.FilterScript(CtrlHelper.GetText(txtLoginName));
            string passwd     = Utility.MD5(CtrlHelper.GetText(txtLoginPass));

            if (!Fetch.ValidVerifyCodeVer2(verifyCode))
            {
                Fetch.Redirect("Login.aspx?errtype=verifycode");
            }

            Base_Users user = new Base_Users( );

            user.Username    = accounts;
            user.Password    = passwd;
            user.LastLoginIP = GameRequest.GetUserIP( );

            Message msg = aidePlatformManagerFacade.UserLogon(user);

            if (!msg.Success)
            {
                string errtype = "errorUnknown";
                switch (msg.MessageID)
                {
                case 100:
                    errtype = "errorNamePassowrd";
                    break;

                case 101:
                    errtype = "errorBindIP";
                    break;

                case 102:
                    errtype = "errorNullity";
                    break;

                default:
                    errtype = "errorUnknown";
                    break;
                }
                Fetch.Redirect(string.Format("Login.aspx?errtype={0}", errtype));
            }
            user = msg.EntityList[0] as Base_Users;
            if (user == null || (user.UserID != ApplicationConfig.SUPER_ADMINISTRATOR_ID && user.RoleID < 0))
            {
                Fetch.Redirect("Login.aspx?errtype=errorUserRole");
            }

            //转向
            Fetch.Redirect("Index.aspx");
        }
Ejemplo n.º 2
0
        //  public static bool isDone = false;
        public static string Login(HttpRequest req)
        {
            string username = req.Form["username"].Trim();
            string password = req.Form["password"];//CryptHelper.Descrypt(username, GameRequest.GetFormString("password"));

            try
            {
                if (!Validate.IsUserName(username))
                {
                    return(JsonResultHelper.GetErrorJson("用户名格式不正确!"));
                }
                else
                {
                    Base_Users user = new Base_Users();
                    user.Username    = username;
                    user.Password    = Utility.MD5(password);
                    user.LastLoginIP = GameRequest.GetUserIP();
                    Message msg = aidePlatformManagerFacade.UserLogon(user);
                    if (!msg.Success)
                    {
                        LogHelper2.SaveErrLog("用户名格式不正确", "", user.UserID, (int)LogOperationEnum.AddGamer, GameRequest.GetUserIP(), "登录模块");
                        return(JsonResultHelper.GetErrorJson(msg.Content));
                    }
                    else
                    {
                        //   isDone = false;
                        LogHelper2.SaveSuccessLog("[" + username + "]成功登录", user.UserID, (int)LogOperationEnum.AddGamer, GameRequest.GetUserIP(), "登录模块");
                        return(JsonResultHelper.GetSuccessJson(msg.Content));
                    }
                }
            }
            catch (Exception ex)
            {
                return(JsonResultHelper.GetErrorJson(ex.Message));
            }
        }