Example #1
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
            });
        }
Example #2
0
        public static void Login(C.Login P, MirConnection Con)
        {
            if (!Settings.AllowLogin)
            {
                Con.QueuePacket(new S.Login {
                    Result = 1
                });
                return;
            }

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

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


            AccountInfo TempAccount = GetAccount(P.AccountID);

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

            if (TempAccount.Banned)
            {
                if (TempAccount.ExpiryDate > DateTime.Now)
                {
                    Con.QueuePacket(new S.LoginBanned {
                        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.Password, false) != 0)
            {
                Con.QueuePacket(new S.Login {
                    Result = 5
                });
                return;
            }

            Network.Disconnect(TempAccount, 1);

            Con.QueuePacket(new S.LoginSuccess {
                CharacterList = TempAccount.GetSelectInfo()
            });

            Con.Account = TempAccount;
            Con.Stage   = GameStage.Select;
        }
Example #3
0
        public static void CreateAccount(C.NewAccount P, MirConnection Con)
        {
            if (!Settings.AllowNewAccount)
            {
                Con.QueuePacket(new S.NewAccount {
                    Result = 1
                });
                return;
            }

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

            if (!PasswordReg.IsMatch(P.Password))
            {
                Con.QueuePacket(new S.NewAccount {
                    Result = 3
                });
                return;
            }
            if (!string.IsNullOrWhiteSpace(P.EMailAddress) && !EMailReg.IsMatch(P.EMailAddress))
            {
                Con.QueuePacket(new S.NewAccount {
                    Result = 4
                });
                return;
            }

            if (!string.IsNullOrWhiteSpace(P.UserName) && P.UserName.Length > 30)
            {
                Con.QueuePacket(new S.NewAccount {
                    Result = 5
                });
                return;
            }

            if (!string.IsNullOrWhiteSpace(P.SecretQuestion) && P.SecretQuestion.Length > 20)
            {
                Con.QueuePacket(new S.NewAccount {
                    Result = 6
                });
                return;
            }

            if (!string.IsNullOrWhiteSpace(P.SecretAnswer) && P.SecretAnswer.Length > 20)
            {
                Con.QueuePacket(new S.NewAccount {
                    Result = 7
                });
                return;
            }

            if (AccountExists(P.AccountID))
            {
                Con.QueuePacket(new S.NewAccount {
                    Result = 8
                });
                return;
            }

            NewAccount(P, Con.IPAddress);

            Con.QueuePacket(new S.NewAccount {
                Result = 9
            });
        }