Exemplo n.º 1
0
        public static void UserAuth(Packet packet)
        {
            int version  = packet.Reader.ReadInt32();
            var username = packet.Reader.ReadUnicodeStatic(40);
            var password = packet.Reader.ReadAscii();

            password = password.Substring(0, password.Length - 1);

            Log.Debug("Login (v{0}) request from {1}", version.ToString(), username);

            if (!AccountModel.AccountExists(AuthServer.Instance.Database.Connection, username))
            {
                Log.Debug("Account {0} not found!", username);
                packet.Sender.Error("Invalid Username or password!");
                return;
            }

            User user = AccountModel.Retrieve(AuthServer.Instance.Database.Connection, username);

            if (user == null)
            {
                Log.Debug("Account {0} not found!", username);
                packet.Sender.Error("Invalid Username or password!");
                return;
            }
            //  var passwordHashed = Password.GenerateSaltedHash(password, user.Salt);
            if (password != user.Password)
            {
                Log.Debug("Account {0} found but invalid password! ({1} ({2}) vs {3})", username, password, user.Salt, user.Password);
                packet.Sender.Error("Invalid Username or password!");
                return;
            }

            uint ticket = AccountModel.CreateSession(AuthServer.Instance.Database.Connection, username);

            // Wrong protocol -> 20070

            /*var ack = new Packet(Packets.UserAuthAck);
             * packet.Sender.Error("Invalid Username or password!");*/

            var ack = new Packet(Packets.UserAuthAck);

            UserAuthAck.Serialize(ticket, ack.Writer);

            packet.Sender.Send(ack);
        }
Exemplo n.º 2
0
        private CommandResult HandlePasswd(string command, IList <string> args)
        {
            if (args.Count < 3)
            {
                return(CommandResult.InvalidArgument);
            }

            var accountName = args[1];
            var password    = args[2];

            if (!AccountModel.AccountExists(AuthServer.Instance.Database.Connection, accountName))
            {
                Log.Error("Please specify an existing account.");
                return(CommandResult.Fail);
            }

            AccountModel.SetAccountPassword(AuthServer.Instance.Database.Connection, accountName, password);

            Log.Info("Password change for {0} complete.", accountName);

            return(CommandResult.Okay);
        }