Example #1
0
        public override bool OnSending()
        {
            Account acct = Accounting.Get((int)Socket.AccountNumber);

            if (acct != null)
            {
                acct.VerifyMobile(Serial);
                unsafe
                {
                    if (Socket.PlayerObject != null)
                    {
                        if (acct.HasAccess(AccountAccessFlags.Admin))
                        {
                            Server.MakeGameMaster((PlayerObject *)Socket.PlayerObject);
                            Player.SetPlayerFlag((class_Player *)Socket.PlayerObject, PlayerFlags.IsEditing);
                            ConsoleUtils.PushColor(ConsoleColor.Red);
                            Console.WriteLine("GM Login.");
                            ConsoleUtils.PopColor();
                        }
                        else
                        {
                            Server.UnmakeGameMaster((PlayerObject *)Socket.PlayerObject);
                            Player.ClearPlayerFlag((class_Player *)Socket.PlayerObject, PlayerFlags.IsEditing | PlayerFlags.IsGod | PlayerFlags.IsGM);
                        }
                    }
                }
            }
            return(true);
        }
Example #2
0
        int TestCreate(string username)
        {
            int newAccountID = TestSuccess(username);

            Account account = Accounting.Get(newAccountID);

            Assert.AreEqual(username, account.Username);

            bool AccountWasCreatedInTheLast1Seconds = account.Created.AddSeconds(1.0) > DateTime.Now;

            Assert.IsTrue(AccountWasCreatedInTheLast1Seconds);

            return(newAccountID);
        }
Example #3
0
        unsafe int TestSuccess(string username)
        {
            using (MockClient client = new MockClient(42, TestUserIP))
            {
                Assert.AreEqual(0u, client.SocketDataLength, "Data length should be zero");

                MockClient_80_Login packetIn = new MockClient_80_Login(client.Socket, username, TestUserPass);
                client.Enqueue(packetIn);

                Assert.AreEqual(packetIn.Length, client.SocketDataLength, "Socket should contain packet, datalength should equal packet length.");

                Packet80_LoginRequest packetOut = null;
                try
                {
                    packetOut = client.ProcessAndCheck(packetIn) as Packet80_LoginRequest;
                }
                catch (VerificationException ex)
                {
                    Assert.Fail(ex.Message);
                }

                Assert.AreEqual(packetIn.Length, client.SocketDataLength, "Socket should still contain packet, as login should have been accepted.");

                int  accountID;
                bool UsernameIsAccountID = int.TryParse(packetOut.Username, out accountID);

                Assert.IsTrue(UsernameIsAccountID, "Expected username to be an account id.");
                Assert.IsTrue(string.IsNullOrEmpty(packetOut.Password), "Password should be empty.");

                Account account = Accounting.Get(accountID);
                Assert.AreEqual(username, account.Username);

                bool passwordIsCorrect = account.Login(TestUserPass, TestUserIP);
                Assert.IsTrue(passwordIsCorrect, "Password didn't work.");

                return(accountID);
            }
        }