static bool HandleAccountPasswordCommand(StringArguments args, CommandHandler handler)
        {
            // If no args are given at all, we can return false right away.
            if (args.Empty())
            {
                handler.SendSysMessage(CypherStrings.CmdSyntax);
                return(false);
            }

            // Command is supposed to be: .account password [$oldpassword] [$newpassword] [$newpasswordconfirmation] [$emailconfirmation]
            string oldPassword          = args.NextString(); // This extracts [$oldpassword]
            string newPassword          = args.NextString(); // This extracts [$newpassword]
            string passwordConfirmation = args.NextString(); // This extracts [$newpasswordconfirmation]

            //Is any of those variables missing for any reason ? We return false.
            if (string.IsNullOrEmpty(oldPassword) || string.IsNullOrEmpty(newPassword) || string.IsNullOrEmpty(passwordConfirmation))
            {
                handler.SendSysMessage(CypherStrings.CmdSyntax);
                return(false);
            }

            // We compare the old, saved password to the entered old password - no chance for the unauthorized.
            if (!Global.BNetAccountMgr.CheckPassword(handler.GetSession().GetBattlenetAccountId(), oldPassword))
            {
                handler.SendSysMessage(CypherStrings.CommandWrongoldpassword);

                Log.outInfo(LogFilter.Player, "Battle.net account: {0} (IP: {1}) Character:[{2}] ({3}) Tried to change password, but the provided old password is wrong.",
                            handler.GetSession().GetBattlenetAccountId(), handler.GetSession().GetRemoteAddress(), handler.GetSession().GetPlayer().GetName(), handler.GetSession().GetPlayer().GetGUID().ToString());
                return(false);
            }

            // Making sure that newly entered password is correctly entered.
            if (newPassword != passwordConfirmation)
            {
                handler.SendSysMessage(CypherStrings.NewPasswordsNotMatch);
                return(false);
            }

            // Changes password and prints result.
            AccountOpResult result = Global.BNetAccountMgr.ChangePassword(handler.GetSession().GetBattlenetAccountId(), newPassword);

            switch (result)
            {
            case AccountOpResult.Ok:
                handler.SendSysMessage(CypherStrings.CommandPassword);
                Log.outInfo(LogFilter.Player, "Battle.net account: {0} (IP: {1}) Character:[{2}] ({3}) Changed Password.",
                            handler.GetSession().GetBattlenetAccountId(), handler.GetSession().GetRemoteAddress(), handler.GetSession().GetPlayer().GetName(), handler.GetSession().GetPlayer().GetGUID().ToString());
                break;

            case AccountOpResult.PassTooLong:
                handler.SendSysMessage(CypherStrings.PasswordTooLong);
                return(false);

            default:
                handler.SendSysMessage(CypherStrings.CommandNotchangepassword);
                return(false);
            }

            return(true);
        }
Пример #2
0
        static bool HandleAccountCreateCommand(StringArguments args, CommandHandler handler)
        {
            if (args.Empty())
            {
                return(false);
            }

            var    accountName = args.NextString().ToUpper();
            var    password    = args.NextString();
            string email       = "";

            if (string.IsNullOrEmpty(accountName) || string.IsNullOrEmpty(password))
            {
                return(false);
            }

            if (accountName.Contains("@"))
            {
                handler.SendSysMessage(CypherStrings.AccountUseBnetCommands);
                return(false);
            }

            AccountOpResult result = Global.AccountMgr.CreateAccount(accountName, password, email);

            switch (result)
            {
            case AccountOpResult.Ok:
                handler.SendSysMessage(CypherStrings.AccountCreated, accountName);
                if (handler.GetSession() != null)
                {
                    Log.outInfo(LogFilter.Player, "Account: {0} (IP: {1}) Character:[{2}] (GUID: {3}) created Account {4} (Email: '{5}')",
                                handler.GetSession().GetAccountId(), handler.GetSession().GetRemoteAddress(),
                                handler.GetSession().GetPlayer().GetName(), handler.GetSession().GetPlayer().GetGUID().ToString(),
                                accountName, email);
                }
                break;

            case AccountOpResult.NameTooLong:
                handler.SendSysMessage(CypherStrings.AccountNameTooLong);
                return(false);

            case AccountOpResult.PassTooLong:
                handler.SendSysMessage(CypherStrings.AccountPassTooLong);
                return(false);

            case AccountOpResult.NameAlreadyExist:
                handler.SendSysMessage(CypherStrings.AccountAlreadyExist);
                return(false);

            case AccountOpResult.DBInternalError:
                handler.SendSysMessage(CypherStrings.AccountNotCreatedSqlError, accountName);
                return(false);

            default:
                handler.SendSysMessage(CypherStrings.AccountNotCreated, accountName);
                return(false);
            }

            return(true);
        }
Пример #3
0
        static bool HandleAccountEmailCommand(CommandHandler handler, string oldEmail, string password, string email, string emailConfirm)
        {
            if (!Global.AccountMgr.CheckEmail(handler.GetSession().GetAccountId(), oldEmail))
            {
                handler.SendSysMessage(CypherStrings.CommandWrongemail);
                Log.outInfo(LogFilter.Player, "Account: {0} (IP: {1}) Character:[{2}] (GUID: {3}) Tried to change email, but the provided email [{4}] is not equal to registration email [{5}].",
                            handler.GetSession().GetAccountId(), handler.GetSession().GetRemoteAddress(),
                            handler.GetSession().GetPlayer().GetName(), handler.GetSession().GetPlayer().GetGUID().ToString(),
                            email, oldEmail);
                return(false);
            }

            if (!Global.AccountMgr.CheckPassword(handler.GetSession().GetAccountId(), password))
            {
                handler.SendSysMessage(CypherStrings.CommandWrongoldpassword);
                Log.outInfo(LogFilter.Player, "Account: {0} (IP: {1}) Character:[{2}] (GUID: {3}) Tried to change email, but the provided password is wrong.",
                            handler.GetSession().GetAccountId(), handler.GetSession().GetRemoteAddress(),
                            handler.GetSession().GetPlayer().GetName(), handler.GetSession().GetPlayer().GetGUID().ToString());
                return(false);
            }

            if (email == oldEmail)
            {
                handler.SendSysMessage(CypherStrings.OldEmailIsNewEmail);
                return(false);
            }

            if (email != emailConfirm)
            {
                handler.SendSysMessage(CypherStrings.NewEmailsNotMatch);
                Log.outInfo(LogFilter.Player, "Account: {0} (IP: {1}) Character:[{2}] (GUID: {3}) Tried to change email, but the provided password is wrong.",
                            handler.GetSession().GetAccountId(), handler.GetSession().GetRemoteAddress(),
                            handler.GetSession().GetPlayer().GetName(), handler.GetSession().GetPlayer().GetGUID().ToString());
                return(false);
            }


            AccountOpResult result = Global.AccountMgr.ChangeEmail(handler.GetSession().GetAccountId(), email);

            switch (result)
            {
            case AccountOpResult.Ok:
                handler.SendSysMessage(CypherStrings.CommandEmail);
                Log.outInfo(LogFilter.Player, "Account: {0} (IP: {1}) Character:[{2}] (GUID: {3}) Changed Email from [{4}] to [{5}].",
                            handler.GetSession().GetAccountId(), handler.GetSession().GetRemoteAddress(),
                            handler.GetSession().GetPlayer().GetName(), handler.GetSession().GetPlayer().GetGUID().ToString(),
                            oldEmail, email);
                break;

            case AccountOpResult.EmailTooLong:
                handler.SendSysMessage(CypherStrings.EmailTooLong);
                return(false);

            default:
                handler.SendSysMessage(CypherStrings.CommandNotchangeemail);
                return(false);
            }

            return(true);
        }
Пример #4
0
        static bool HandleAccountPasswordCommand(CommandHandler handler, string oldPassword, string newPassword, string confirmPassword, string confirmEmail)
        {
            // First, we check config. What security type (sec type) is it ? Depending on it, the command branches out
            uint pwConfig = WorldConfig.GetUIntValue(WorldCfg.AccPasschangesec); // 0 - PW_NONE, 1 - PW_EMAIL, 2 - PW_RBAC

            // We compare the old, saved password to the entered old password - no chance for the unauthorized.
            if (!Global.AccountMgr.CheckPassword(handler.GetSession().GetAccountId(), oldPassword))
            {
                handler.SendSysMessage(CypherStrings.CommandWrongoldpassword);

                Log.outInfo(LogFilter.Player, "Account: {0} (IP: {1}) Character:[{2}] (GUID: {3}) Tried to change password, but the provided old password is wrong.",
                            handler.GetSession().GetAccountId(), handler.GetSession().GetRemoteAddress(),
                            handler.GetSession().GetPlayer().GetName(), handler.GetSession().GetPlayer().GetGUID().ToString());
                return(false);
            }
            // This compares the old, current email to the entered email - however, only...
            if ((pwConfig == 1 || (pwConfig == 2 && handler.GetSession().HasPermission(RBACPermissions.EmailConfirmForPassChange))) && // ...if either PW_EMAIL or PW_RBAC with the Permission is active...
                !Global.AccountMgr.CheckEmail(handler.GetSession().GetAccountId(), confirmEmail))    // ... and returns false if the comparison fails.
            {
                handler.SendSysMessage(CypherStrings.CommandWrongemail);

                Log.outInfo(LogFilter.Player, "Account: {0} (IP: {1}) Character:[{2}] (GUID: {3}) Tried to change password, but the entered email [{4}] is wrong.",
                            handler.GetSession().GetAccountId(), handler.GetSession().GetRemoteAddress(),
                            handler.GetSession().GetPlayer().GetName(), handler.GetSession().GetPlayer().GetGUID().ToString(),
                            confirmEmail);
                return(false);
            }

            // Making sure that newly entered password is correctly entered.
            if (newPassword != confirmPassword)
            {
                handler.SendSysMessage(CypherStrings.NewPasswordsNotMatch);
                return(false);
            }

            // Changes password and prints result.
            AccountOpResult result = Global.AccountMgr.ChangePassword(handler.GetSession().GetAccountId(), newPassword);

            switch (result)
            {
            case AccountOpResult.Ok:
                handler.SendSysMessage(CypherStrings.CommandPassword);
                Log.outInfo(LogFilter.Player, "Account: {0} (IP: {1}) Character:[{2}] (GUID: {3}) Changed Password.",
                            handler.GetSession().GetAccountId(), handler.GetSession().GetRemoteAddress(),
                            handler.GetSession().GetPlayer().GetName(), handler.GetSession().GetPlayer().GetGUID().ToString());
                break;

            case AccountOpResult.PassTooLong:
                handler.SendSysMessage(CypherStrings.PasswordTooLong);
                return(false);

            default:
                handler.SendSysMessage(CypherStrings.CommandNotchangepassword);
                return(false);
            }

            return(true);
        }
            static bool HandleSetPasswordCommand(StringArguments args, CommandHandler handler)
            {
                if (args.Empty())
                {
                    handler.SendSysMessage(CypherStrings.CmdSyntax);
                    return(false);
                }

                // Get the command line arguments
                string accountName          = args.NextString();
                string password             = args.NextString();
                string passwordConfirmation = args.NextString();

                if (string.IsNullOrEmpty(accountName) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(passwordConfirmation))
                {
                    return(false);
                }

                uint targetAccountId = Global.BNetAccountMgr.GetId(accountName);

                if (targetAccountId == 0)
                {
                    handler.SendSysMessage(CypherStrings.AccountNotExist, accountName);
                    return(false);
                }

                if (password != passwordConfirmation)
                {
                    handler.SendSysMessage(CypherStrings.NewPasswordsNotMatch);
                    return(false);
                }

                AccountOpResult result = Global.BNetAccountMgr.ChangePassword(targetAccountId, password);

                switch (result)
                {
                case AccountOpResult.Ok:
                    handler.SendSysMessage(CypherStrings.CommandPassword);
                    break;

                case AccountOpResult.NameNotExist:
                    handler.SendSysMessage(CypherStrings.AccountNotExist, accountName);
                    return(false);

                case AccountOpResult.PassTooLong:
                    handler.SendSysMessage(CypherStrings.PasswordTooLong);
                    return(false);

                default:
                    break;
                }
                return(true);
            }
Пример #6
0
        static bool HandleAccountDeleteCommand(StringArguments args, CommandHandler handler)
        {
            if (args.Empty())
            {
                return(false);
            }

            string accountName = args.NextString();

            if (string.IsNullOrEmpty(accountName))
            {
                return(false);
            }

            uint accountId = Global.AccountMgr.GetId(accountName);

            if (accountId == 0)
            {
                handler.SendSysMessage(CypherStrings.AccountNotExist, accountName);
                return(false);
            }

            if (handler.HasLowerSecurityAccount(null, accountId, true))
            {
                return(false);
            }

            AccountOpResult result = Global.AccountMgr.DeleteAccount(accountId);

            switch (result)
            {
            case AccountOpResult.Ok:
                handler.SendSysMessage(CypherStrings.AccountDeleted, accountName);
                break;

            case AccountOpResult.NameNotExist:
                handler.SendSysMessage(CypherStrings.AccountNotExist, accountName);
                return(false);

            case AccountOpResult.DBInternalError:
                handler.SendSysMessage(CypherStrings.AccountNotDeletedSqlError, accountName);
                return(false);

            default:
                handler.SendSysMessage(CypherStrings.AccountNotDeleted, accountName);
                return(false);
            }

            return(true);
        }
Пример #7
0
                static bool HandleAccountSetRegEmailCommand(CommandHandler handler, string accountName, string email, string confirmEmail)
                {
                    uint targetAccountId = Global.AccountMgr.GetId(accountName);

                    if (targetAccountId == 0)
                    {
                        handler.SendSysMessage(CypherStrings.AccountNotExist, accountName);
                        return(false);
                    }

                    // can set email only for target with less security
                    // This also restricts setting handler's own email.
                    if (handler.HasLowerSecurityAccount(null, targetAccountId, true))
                    {
                        return(false);
                    }

                    if (!email.Equals(confirmEmail))
                    {
                        handler.SendSysMessage(CypherStrings.NewEmailsNotMatch);
                        return(false);
                    }

                    AccountOpResult result = Global.AccountMgr.ChangeRegEmail(targetAccountId, email);

                    switch (result)
                    {
                    case AccountOpResult.Ok:
                        handler.SendSysMessage(CypherStrings.CommandEmail);
                        Log.outInfo(LogFilter.Player, "ChangeRegEmail: Account {0} [Id: {1}] had it's Registration Email changed to {2}.", accountName, targetAccountId, email);
                        break;

                    case AccountOpResult.NameNotExist:
                        handler.SendSysMessage(CypherStrings.AccountNotExist, accountName);
                        return(false);

                    case AccountOpResult.EmailTooLong:
                        handler.SendSysMessage(CypherStrings.EmailTooLong);
                        return(false);

                    default:
                        handler.SendSysMessage(CypherStrings.CommandNotchangeemail);
                        return(false);
                    }

                    return(true);
                }
Пример #8
0
            static bool HandleAccountSetPasswordCommand(CommandHandler handler, string accountName, string password, string confirmPassword)
            {
                uint targetAccountId = Global.AccountMgr.GetId(accountName);

                if (targetAccountId == 0)
                {
                    handler.SendSysMessage(CypherStrings.AccountNotExist, accountName);
                    return(false);
                }

                // can set password only for target with less security
                // This also restricts setting handler's own password
                if (handler.HasLowerSecurityAccount(null, targetAccountId, true))
                {
                    return(false);
                }

                if (!password.Equals(confirmPassword))
                {
                    handler.SendSysMessage(CypherStrings.NewPasswordsNotMatch);
                    return(false);
                }

                AccountOpResult result = Global.AccountMgr.ChangePassword(targetAccountId, password);

                switch (result)
                {
                case AccountOpResult.Ok:
                    handler.SendSysMessage(CypherStrings.CommandPassword);
                    break;

                case AccountOpResult.NameNotExist:
                    handler.SendSysMessage(CypherStrings.AccountNotExist, accountName);
                    return(false);

                case AccountOpResult.PassTooLong:
                    handler.SendSysMessage(CypherStrings.PasswordTooLong);
                    return(false);

                default:
                    handler.SendSysMessage(CypherStrings.CommandNotchangepassword);
                    return(false);
                }

                return(true);
            }
Пример #9
0
                static bool HandleSetRegEmailCommand(StringArguments args, CommandHandler handler)
                {
                    if (args.Empty())
                    {
                        return(false);
                    }

                    //- We do not want anything short of console to use this by default.
                    //- So we force that.
                    if (handler.GetSession())
                    {
                        return(false);
                    }

                    // Get the command line arguments
                    string accountName       = args.NextString();
                    string email             = args.NextString();
                    string emailConfirmation = args.NextString();

                    if (string.IsNullOrEmpty(accountName) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(emailConfirmation))
                    {
                        handler.SendSysMessage(CypherStrings.CmdSyntax);
                        return(false);
                    }

                    uint targetAccountId = Global.AccountMgr.GetId(accountName);

                    if (targetAccountId == 0)
                    {
                        handler.SendSysMessage(CypherStrings.AccountNotExist, accountName);
                        return(false);
                    }

                    // can set email only for target with less security
                    // This also restricts setting handler's own email.
                    if (handler.HasLowerSecurityAccount(null, targetAccountId, true))
                    {
                        return(false);
                    }

                    if (!email.Equals(emailConfirmation))
                    {
                        handler.SendSysMessage(CypherStrings.NewEmailsNotMatch);
                        return(false);
                    }

                    AccountOpResult result = Global.AccountMgr.ChangeRegEmail(targetAccountId, email);

                    switch (result)
                    {
                    case AccountOpResult.Ok:
                        handler.SendSysMessage(CypherStrings.CommandEmail);
                        Log.outInfo(LogFilter.Player, "ChangeRegEmail: Account {0} [Id: {1}] had it's Registration Email changed to {2}.", accountName, targetAccountId, email);
                        break;

                    case AccountOpResult.NameNotExist:
                        handler.SendSysMessage(CypherStrings.AccountNotExist, accountName);
                        return(false);

                    case AccountOpResult.EmailTooLong:
                        handler.SendSysMessage(CypherStrings.EmailTooLong);
                        return(false);

                    default:
                        handler.SendSysMessage(CypherStrings.CommandNotchangeemail);
                        return(false);
                    }

                    return(true);
                }
Пример #10
0
            static bool HandleSetPasswordCommand(StringArguments args, CommandHandler handler)
            {
                if (args.Empty())
                {
                    handler.SendSysMessage(CypherStrings.CmdSyntax);
                    return(false);
                }

                // Get the command line arguments
                string accountName          = args.NextString();
                string password             = args.NextString();
                string passwordConfirmation = args.NextString();

                if (string.IsNullOrEmpty(accountName) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(passwordConfirmation))
                {
                    return(false);
                }

                uint targetAccountId = Global.AccountMgr.GetId(accountName);

                if (targetAccountId == 0)
                {
                    handler.SendSysMessage(CypherStrings.AccountNotExist, accountName);
                    return(false);
                }

                // can set password only for target with less security
                // This also restricts setting handler's own password
                if (handler.HasLowerSecurityAccount(null, targetAccountId, true))
                {
                    return(false);
                }

                if (!password.Equals(passwordConfirmation))
                {
                    handler.SendSysMessage(CypherStrings.NewPasswordsNotMatch);
                    return(false);
                }

                AccountOpResult result = Global.AccountMgr.ChangePassword(targetAccountId, password);

                switch (result)
                {
                case AccountOpResult.Ok:
                    handler.SendSysMessage(CypherStrings.CommandPassword);
                    break;

                case AccountOpResult.NameNotExist:
                    handler.SendSysMessage(CypherStrings.AccountNotExist, accountName);
                    return(false);

                case AccountOpResult.PassTooLong:
                    handler.SendSysMessage(CypherStrings.PasswordTooLong);
                    return(false);

                default:
                    handler.SendSysMessage(CypherStrings.CommandNotchangepassword);
                    return(false);
                }
                return(true);
            }
Пример #11
0
        static bool HandleAccountPasswordCommand(StringArguments args, CommandHandler handler)
        {
            // If no args are given at all, we can return false right away.
            if (args.Empty())
            {
                handler.SendSysMessage(CypherStrings.CmdSyntax);
                return(false);
            }

            // First, we check config. What security type (sec type) is it ? Depending on it, the command branches out
            uint pwConfig = WorldConfig.GetUIntValue(WorldCfg.AccPasschangesec); // 0 - PW_NONE, 1 - PW_EMAIL, 2 - PW_RBAC

            // Command is supposed to be: .account password [$oldpassword] [$newpassword] [$newpasswordconfirmation] [$emailconfirmation]
            string oldPassword          = args.NextString(); // This extracts [$oldpassword]
            string newPassword          = args.NextString(); // This extracts [$newpassword]
            string passwordConfirmation = args.NextString(); // This extracts [$newpasswordconfirmation]
            string emailConfirmation    = args.NextString(); // This defines the emailConfirmation variable, which is optional depending on sec type.

            //Is any of those variables missing for any reason ? We return false.
            if (string.IsNullOrEmpty(oldPassword) || string.IsNullOrEmpty(newPassword) ||
                string.IsNullOrEmpty(passwordConfirmation))
            {
                handler.SendSysMessage(CypherStrings.CmdSyntax);

                return(false);
            }

            // We compare the old, saved password to the entered old password - no chance for the unauthorized.
            if (!Global.AccountMgr.CheckPassword(handler.GetSession().GetAccountId(), oldPassword))
            {
                handler.SendSysMessage(CypherStrings.CommandWrongoldpassword);

                Log.outInfo(LogFilter.Player, "Account: {0} (IP: {1}) Character:[{2}] (GUID: {3}) Tried to change password, but the provided old password is wrong.",
                            handler.GetSession().GetAccountId(), handler.GetSession().GetRemoteAddress(),
                            handler.GetSession().GetPlayer().GetName(), handler.GetSession().GetPlayer().GetGUID().ToString());
                return(false);
            }
            // This compares the old, current email to the entered email - however, only...
            if ((pwConfig == 1 || (pwConfig == 2 && handler.GetSession().HasPermission(RBACPermissions.EmailConfirmForPassChange))) && // ...if either PW_EMAIL or PW_RBAC with the Permission is active...
                !Global.AccountMgr.CheckEmail(handler.GetSession().GetAccountId(), emailConfirmation))    // ... and returns false if the comparison fails.
            {
                handler.SendSysMessage(CypherStrings.CommandWrongemail);

                Log.outInfo(LogFilter.Player, "Account: {0} (IP: {1}) Character:[{2}] (GUID: {3}) Tried to change password, but the entered email [{4}] is wrong.",
                            handler.GetSession().GetAccountId(), handler.GetSession().GetRemoteAddress(),
                            handler.GetSession().GetPlayer().GetName(), handler.GetSession().GetPlayer().GetGUID().ToString(),
                            emailConfirmation);
                return(false);
            }

            // Making sure that newly entered password is correctly entered.
            if (newPassword != passwordConfirmation)
            {
                handler.SendSysMessage(CypherStrings.NewPasswordsNotMatch);
                return(false);
            }

            // Changes password and prints result.
            AccountOpResult result = Global.AccountMgr.ChangePassword(handler.GetSession().GetAccountId(), newPassword);

            switch (result)
            {
            case AccountOpResult.Ok:
                handler.SendSysMessage(CypherStrings.CommandPassword);
                Log.outInfo(LogFilter.Player, "Account: {0} (IP: {1}) Character:[{2}] (GUID: {3}) Changed Password.",
                            handler.GetSession().GetAccountId(), handler.GetSession().GetRemoteAddress(),
                            handler.GetSession().GetPlayer().GetName(), handler.GetSession().GetPlayer().GetGUID().ToString());
                break;

            case AccountOpResult.PassTooLong:
                handler.SendSysMessage(CypherStrings.PasswordTooLong);
                return(false);

            default:
                handler.SendSysMessage(CypherStrings.CommandNotchangepassword);
                return(false);
            }

            return(true);
        }