Beispiel #1
0
 public override bool TakeAction()
 {
     try
     {
         DESAlgorithmNew des = new DESAlgorithmNew();
         password = des.DecodePwd(password, GameEnvironment.Setting.ClientDesDeKey);
         if (password.Length > 12 || password.Length < 4)
         {
             this.ErrorCode = LanguageManager.GetLang().ErrorCode;
             this.ErrorInfo = LanguageManager.GetLang().St1006_PasswordTooLong;
             return false;
         }
         password = CryptoHelper.DES_Encrypt(password, GameEnvironment.Setting.ProductDesEnKey);
         if (SnsManager.ChangePass(Uid, password) <= 0)
         {
             this.ErrorCode = LanguageManager.GetLang().ErrorCode;
             ErrorInfo = LanguageManager.GetLang().St1006_ChangePasswordError;
             return false;
         }
     }
     catch (Exception ex)
     {
         this.SaveLog(ex.ToString());
         ErrorCode = LanguageManager.GetLang().ErrorCode;
         ErrorInfo = LanguageManager.GetLang().St1006_PasswordError;
         return false;
     }
     return true;
 }
Beispiel #2
0
		/// <summary>
		/// 
		/// </summary>
		/// <returns></returns>
        public override bool CheckLogin()
        {
            string pwd = Password;
            try
            {
                pwd = new DESAlgorithmNew().DecodePwd(pwd, GameEnvironment.Setting.ClientDesDeKey);
            }
            catch (Exception ex)
            {
                TraceLog.WriteError("Decode pwd error:{0}", ex);
            }
            pwd = CryptoHelper.DES_Encrypt(pwd, GameEnvironment.Setting.ProductDesEnKey);
            Password = pwd;
            //快速登录
            UserID = SnsManager.LoginByDevice(PassportID, Password, DeviceID).ToString();

            if (!string.IsNullOrEmpty(UserID) && UserID != "0")
            {
                UserType = SnsManager.GetUserType(PassportID);
                if (string.IsNullOrEmpty(SessionID))
                {
                    SessionID = GetSessionId();
                }
                return true;
            }
            //TraceLog.WriteError("LoginByDevice pid:{0},pwd:{1},device:{2},uid:{3}", PassportID, Password, DeviceID, UserID);
            return false;
        }
Beispiel #3
0
 public override bool TakeAction()
 {
     try
     {
         DESAlgorithmNew des = new DESAlgorithmNew();
         password = des.DecodePwd(password, GameEnvironment.Setting.ClientDesDeKey);
         if (password.Length > 12 || password.Length < 4)
         {
             this.ErrorCode = Language.Instance.ErrorCode;
             this.ErrorInfo = Language.Instance.St1006_PasswordTooLong;
             return false;
         }
         if (SnsManager.ChangePass(UserId.ToString(), password) <= 0)
         {
             this.ErrorCode = Language.Instance.ErrorCode;
             ErrorInfo = Language.Instance.St1006_ChangePasswordError;
             return false;
         }
     }
     catch (Exception ex)
     {
         this.SaveLog(ex.ToString());
         ErrorCode = Language.Instance.ErrorCode;
         ErrorInfo = Language.Instance.St1006_PasswordError;
         return false;
     }
     return true;
 }
Beispiel #4
0
        public override bool TakeAction()
        {
            try
            {
                DESAlgorithmNew des = new DESAlgorithmNew();
                password = des.DecodePwd(password, "n7=7=7dk");
                if (password.Length > 12 || password.Length < 4)
                {
                    this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                    this.ErrorInfo = LanguageManager.GetLang().St1006_PasswordTooLong;
                    return false;
                }
                Regex re = new Regex(@"^[\u4e00-\u9fa5\w]+$");
                if (!re.IsMatch(password))
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St1006_PasswordExceptional;
                    return false;
                }
                password = CryptoHelper.DES_Encrypt(password, "5^1-34E!");
                if (SnsManager.ChangePass(Uid, password) <= 0)
                {
                    this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St1006_ChangePasswordError;
                    return false;
                }
                else
                {
                    UserOperationLog userOperationLog = new UserOperationLog();
                    userOperationLog.UserID = ContextUser.UserID;
                    userOperationLog.ActionID = ActionIDDefine.Cst_Action1006;
                    userOperationLog.FunctionID = "更新密码";
                    userOperationLog.CreateDate = DateTime.Now;
                    userOperationLog.Num = 0;

                    var sender = DataSyncManager.GetDataSender();
                    sender.Send(userOperationLog);
                }
            }
            catch (Exception ex)
            {
                this.SaveLog(ex.ToString());
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1006_PasswordError;
                return false;
            }
            return true;
        }
Beispiel #5
0
        private static string GetRequestParams(string sid, string uid, int contractId, int slnId, string pid, string pwd, int gameId, int serverId, string paramList = "")
        {
            string[] paramArray = null;
            if (paramList != null)
            {
                paramArray = paramList.Split(new char[] { ',', ',', ' ', ';' });
            }

            StringBuilder requestParams = new StringBuilder();
            requestParams.AppendFormat("MsgId=1&Sid={0}&Uid={1}&ActionID={2}", sid, uid, contractId);
            if (gameId > 0)
            {
                requestParams.AppendFormat("&GameType={0}", gameId);
            }
            if (serverId > 0)
            {
                requestParams.AppendFormat("&ServerID={0}", serverId);
            }
            int paramType = 1;
            var paramRecords = DbDataLoader.GetParamInfo(slnId, contractId, paramType);

            int i = 0;
            foreach (var record in paramRecords)
            {
                if (requestParams.Length > 0)
                {
                    requestParams.Append("&");
                }
                string fieldName = record.Field;
                string fieldValue = record.FieldValue;

                if (contractId == LoginActionId)
                {
                    if (fieldName.ToLower().Equals("pid"))
                    {
                        fieldValue = string.IsNullOrEmpty(pid)
                                         ? fieldValue
                                         : pid;
                    }
                    else if (fieldName.ToLower().Equals("pwd"))
                    {
                        fieldValue = string.IsNullOrEmpty(pwd)
                                         ? fieldValue
                                         : pwd;
                        fieldValue = new DESAlgorithmNew().EncodePwd(fieldValue, NetHelper.ClientDesDeKey);
                        fieldValue = HttpUtility.UrlEncode(fieldValue, Encoding.UTF8);
                    }
                }
                else
                {
                    if (paramArray != null && i < paramArray.Length && !string.IsNullOrEmpty(paramArray[i]))
                    {
                        fieldValue = paramArray[i];
                    }
                }
                requestParams.AppendFormat("{0}={1}", fieldName, fieldValue);
                i++;
            }
            return requestParams.ToString();
        }
Beispiel #6
0
 private string FormatPostParam(int contractId, List<ParamInfoModel> paramList, string text)
 {
     StringBuilder requestParams = new StringBuilder();
     string[] line = text.Split('\r', '\n');
     foreach (var str in line)
     {
         string[] paramArray = str.Split('=');
         if (paramArray.Length > 1)
         {
             string name = paramArray[0].Trim();
             string value = paramArray.Length > 2 ? string.Join("=", paramArray, 1, paramArray.Length - 1) : paramArray[1];
             value = value.Trim();
             var record = paramList.Find(t => string.Equals(t.Field, name, StringComparison.CurrentCultureIgnoreCase));
             //自动登录
             if (NetHelper.LoginActionId.IndexOf(contractId.ToString(), StringComparison.OrdinalIgnoreCase) != -1)
             {
                 if ("Pid".Equals(name, StringComparison.OrdinalIgnoreCase)) SetCookies("Debug_User", value);
                 if ("Pwd".Equals(name, StringComparison.OrdinalIgnoreCase)) SetCookies("Debug_Pwd", value);
                 if ("DeviceID".Equals(name, StringComparison.OrdinalIgnoreCase)) SetCookies("Debug_DeviceID", value);
                 if ("IMEI".Equals(name, StringComparison.OrdinalIgnoreCase)) SetCookies("Debug_IMEI", value);
                 if ("Token".Equals(name, StringComparison.OrdinalIgnoreCase)) SetCookies("Debug_Token", value);
             }
             if (record != null && record.FieldType == FieldType.Password)
             {
                 value = new DESAlgorithmNew().EncodePwd(value, NetHelper.ClientDesDeKey);
             }
             value = HttpUtility.UrlEncode(value, Encoding.UTF8);
             requestParams.AppendFormat("{0}={1}&", name, value);
         }
     }
     return requestParams.ToString().TrimEnd('&');
 }
Beispiel #7
0
 private string EncodePwdAndUrlEncode(string pwd)
 {
     pwd = new DESAlgorithmNew().EncodePwd(pwd, ConfigUtils.GetSetting("User.Password.EncodeKey"));
     return System.Web.HttpUtility.UrlEncode(pwd);
 }
Beispiel #8
0
 private string FormatPostParam(List<ParamInfoModel> paramList, string text)
 {
     StringBuilder requestParams = new StringBuilder();
     string[] line = text.Split('\r', '\n');
     foreach (var str in line)
     {
         string[] paramArray = str.Split('=');
         if (paramArray.Length > 1)
         {
             string name = paramArray[0].Trim();
             string value = paramArray.Length > 2 ? string.Join("=", paramArray, 1, paramArray.Length - 1) : paramArray[1];
             value = value.Trim();
             var record = paramList.Find(t => string.Equals(t.Field, name, StringComparison.CurrentCultureIgnoreCase));
             if (record != null && record.FieldType == FieldType.Password)
             {
                 value = new DESAlgorithmNew().EncodePwd(value, NetHelper.ClientDesDeKey);
             }
             value = HttpUtility.UrlEncode(value, Encoding.UTF8);
             requestParams.AppendFormat("{0}={1}&", name, value);
         }
     }
     return requestParams.ToString().TrimEnd('&');
 }
Beispiel #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ZyGames.Framework.Game.Sns.LoginDangLe"/> class.
 /// </summary>
 /// <param name="retailId">Retail id.</param>
 /// <param name="retailUser">Retail user id.</param>
 /// <param name="password">Password.</param>
 /// <param name="passportId">Passport id.</param>
 public LoginDangLe(string retailId, string retailUser, string password, string passportId) {
     this.retailId = retailId;
     this.retailUser = HttpUtility.UrlEncode(retailUser, Encoding.UTF8).ToUpper();
     Password = new DESAlgorithmNew().DecodePwd(password, GameEnvironment.Setting.ClientDesDeKey);
     mid = passportId.Equals("0") ? string.Empty : passportId;
 }