Exemplo n.º 1
0
 public static void SelectChanelRequest(IRealmClient client, RealmPacketIn packet)
 {
     if (client.AuthAccount == null)
     {
         AuthenticationHandler.OnLoginError(client, AccountStatus.CloseClient);
     }
     else
     {
         ServerApp <WCell.RealmServer.RealmServer> .IOQueue.AddMessage(
             (IMessage) new Message1 <IRealmClient>(client,
                                                    new Action <IRealmClient>(AuthenticationHandler.SendCharacterNamesResponse)));
     }
 }
Exemplo n.º 2
0
 private static void AuthChallengeRequestCallback(IRealmClient client)
 {
     if (!client.IsConnected)
     {
         return;
     }
     if (BanMgr.IsBanned(client.ClientAddress))
     {
         AuthenticationHandler.OnLoginError(client, AccountStatus.CloseClient);
     }
     else
     {
         ServerApp <WCell.RealmServer.RealmServer> .IOQueue.AddMessage((Action)(() =>
         {
             Account account = AccountMgr.GetAccount(client.AccountName);
             if (account == null)
             {
                 if (RealmServerConfiguration.AutocreateAccounts)
                 {
                     AuthenticationHandler.QueryAccountCallback(client, (Account)null);
                 }
                 else
                 {
                     AuthenticationHandler.OnLoginError(client, AccountStatus.WrongLoginOrPass);
                 }
             }
             else if (account.Password != client.Password)
             {
                 if (client.ClientAddress != null)
                 {
                     Log.Create(Log.Types.AccountOperations, LogSourceType.Account, (uint)account.AccountId)
                     .AddAttribute("operation", 1.0, "login_wrong_pass")
                     .AddAttribute("name", 0.0, account.Name)
                     .AddAttribute("ip", 0.0, client.ClientAddress.ToString()).Write();
                 }
                 AuthenticationHandler.OnLoginError(client, AccountStatus.WrongLoginOrPass);
             }
             else
             {
                 AuthenticationHandler.QueryAccountCallback(client, account);
             }
         }));
     }
 }
Exemplo n.º 3
0
        private static void QueryAccountCallback(IRealmClient client, Account acct)
        {
            if (client == null || !client.IsConnected)
            {
                return;
            }
            if (acct != null)
            {
                Character characterByAccId = World.GetCharacterByAccId((uint)acct.AccountId);
                if (characterByAccId != null)
                {
                    characterByAccId.Logout(true, 0);
                    AuthenticationHandler.OnLoginError(client,
                                                       AccountStatus.WrongLoginOrPass | AccountStatus.AccountInUse);
                    return;
                }
            }

            string       accountName     = client.AccountName;
            RealmAccount loggedInAccount =
                ServerApp <WCell.RealmServer.RealmServer> .Instance.GetLoggedInAccount(accountName);

            if (acct != null && acct.IsLogedOn)
            {
                Log.Create(Log.Types.AccountOperations, LogSourceType.Account, (uint)acct.AccountId)
                .AddAttribute("operation", 1.0, "account_in_use").AddAttribute("name", 0.0, acct.Name)
                .AddAttribute("ip", 0.0, client.ClientAddress.ToString()).Write();
                AuthenticationHandler.OnLoginError(client, AccountStatus.AccountInUse);
            }
            else if (loggedInAccount != null && loggedInAccount.ActiveCharacter != null &&
                     (loggedInAccount.Client != null && loggedInAccount.Client.IsConnected))
            {
                Log.Create(Log.Types.AccountOperations, LogSourceType.Account, (uint)acct.AccountId)
                .AddAttribute("operation", 1.0, "account_in_use").AddAttribute("name", 0.0, acct.Name)
                .AddAttribute("ip", 0.0, client.ClientAddress.ToString()).Write();
                AuthenticationHandler.OnLoginError(client, AccountStatus.AccountInUse);
            }
            else
            {
                if (acct == null)
                {
                    if (RealmServerConfiguration.AutocreateAccounts)
                    {
                        if (!AccountMgr.NameValidator(ref accountName) || client.Password == null ||
                            client.Password.Length > 20)
                        {
                            AuthenticationHandler.OnLoginError(client, AccountStatus.WrongLoginOrPass);
                            return;
                        }

                        client.AuthAccount = AccountMgr.Instance.CreateAccount(accountName, client.Password, "",
                                                                               RealmServerConfiguration.DefaultRole);
                        client.AuthAccount.Save();
                        AuthenticationHandler.SendAuthChallengeSuccessReply(client);
                        client.AuthAccount.IsLogedOn = true;
                    }
                    else
                    {
                        AuthenticationHandler.OnLoginError(client, AccountStatus.WrongLoginOrPass);
                        return;
                    }
                }
                else if (acct.CheckActive())
                {
                    client.AuthAccount = acct;
                    if (loggedInAccount == null)
                    {
                        AuthenticationHandler.SendAuthChallengeSuccessReply(client);
                    }
                }
                else
                {
                    Log.Create(Log.Types.AccountOperations, LogSourceType.Account, (uint)acct.AccountId)
                    .AddAttribute("operation", 1.0, "login_banned").AddAttribute("name", 0.0, acct.Name)
                    .AddAttribute("ip", 0.0, client.ClientAddress.ToString()).Write();
                    if (client.AuthAccount == null || !client.AuthAccount.StatusUntil.HasValue)
                    {
                        AuthenticationHandler.OnLoginError(client, AccountStatus.WrongLoginOrPass);
                        return;
                    }

                    AuthenticationHandler.OnLoginError(client, AccountStatus.WrongLoginOrPass);
                    return;
                }

                if (loggedInAccount == null)
                {
                    if (acct != null)
                    {
                        Log.Create(Log.Types.AccountOperations, LogSourceType.Account, (uint)acct.AccountId)
                        .AddAttribute("operation", 1.0, "login_ok").AddAttribute("name", 0.0, acct.Name)
                        .AddAttribute("ip", 0.0, client.ClientAddress.ToString()).Write();
                    }
                    RealmAccount.InitializeAccount(client, client.AuthAccount.Name);
                }
                else
                {
                    if (acct == null)
                    {
                        return;
                    }
                    if (loggedInAccount.Client != null)
                    {
                        if (loggedInAccount.Client.ActiveCharacter != null)
                        {
                            loggedInAccount.Client.ActiveCharacter.SendInfoMsg(
                                "Some one loggin in to your account. Disconnecting.");
                        }
                        loggedInAccount.Client.Disconnect(false);
                    }

                    if (client.ClientAddress == null)
                    {
                        return;
                    }
                    loggedInAccount.LastIP = client.ClientAddress.GetAddressBytes();
                    acct.LastIP            = client.ClientAddress.GetAddressBytes();
                    acct.Save();
                    client.Account = loggedInAccount;
                    if (loggedInAccount.ActiveCharacter != null)
                    {
                        AuthenticationHandler.ConnectClientToIngameCharacter(client, acct, loggedInAccount);
                    }
                    else
                    {
                        Log.Create(Log.Types.AccountOperations, LogSourceType.Account, (uint)acct.AccountId)
                        .AddAttribute("operation", 1.0, "character_select_menu")
                        .AddAttribute("name", 0.0, acct.Name)
                        .AddAttribute("ip", 0.0, client.ClientAddress.ToString()).Write();
                        AuthenticationHandler.SendAuthChallengeSuccessReply(client);
                    }
                }
            }
        }
Exemplo n.º 4
0
 public static void OnLoginError(IRealmClient client, AccountStatus error)
 {
     AuthenticationHandler.OnLoginError(client, error, false);
 }