Пример #1
0
        public void ChangePassword(C.ChangePassword P)
        {
            if (Stage != GameStage.Login)
            {
                return;
            }

            MirDB.ChangePassword(P, this);
        }
Пример #2
0
        public static void ChangePassword(C.ChangePassword P, MirConnection Con)
        {
            if (!Settings.AllowChangePassword)
            {
                Con.QueuePacket(new S.ChangePassword {
                    Result = 1
                });
                return;
            }

            if (!AccountIDReg.IsMatch(P.AccountID))
            {
                Con.QueuePacket(new S.ChangePassword {
                    Result = 2
                });
                return;
            }

            if (!PasswordReg.IsMatch(P.CurrentPassword))
            {
                Con.QueuePacket(new S.ChangePassword {
                    Result = 3
                });
                return;
            }

            if (!PasswordReg.IsMatch(P.NewPassword))
            {
                Con.QueuePacket(new S.ChangePassword {
                    Result = 4
                });
                return;
            }


            AccountInfo TempAccount = GetAccount(P.AccountID);

            if (TempAccount == null)
            {
                Con.QueuePacket(new S.ChangePassword {
                    Result = 5
                });
                return;
            }

            if (TempAccount.Banned)
            {
                if (TempAccount.ExpiryDate > Main.Now)
                {
                    Con.QueuePacket(new S.ChangePasswordBanned {
                        Reason = TempAccount.BanReason, ExpiryDate = TempAccount.ExpiryDate
                    });
                    return;
                }
                else
                {
                    TempAccount.Banned     = false;
                    TempAccount.BanReason  = string.Empty;
                    TempAccount.ExpiryDate = DateTime.MinValue;
                }
            }

            if (string.Compare(TempAccount.Password, P.CurrentPassword, false) != 0)
            {
                Con.QueuePacket(new S.ChangePassword {
                    Result = 6
                });
                return;
            }

            TempAccount.Password = P.NewPassword;
            Con.QueuePacket(new S.ChangePassword {
                Result = 7
            });
        }