コード例 #1
0
        internal static AionAuthResponse Login(string userName, string password, AionConnection client)
        {
            Account account = LoadAccount(userName);

            if (Information.IsNothing(account) & LoginConfig.ACCOUNT_AUTO_CREATION)
            {
                account = CreateAccount(userName, password);
            }
            if (Information.IsNothing(account))
            {
                return(AionAuthResponse.INVALID_PASSWORD);
            }
            if (!account.Password.Equals(RuntimeHelpers.GetObjectValue(EncodePassword(password))))
            {
                if (LoginConfig.PASSWORD_CHECK_ENABLE)
                {
                    BruteForceProtector.AddFailedLogin(userName, client.IP);
                }
                return(AionAuthResponse.INVALID_PASSWORD);
            }
            if (account.Activated != 1)
            {
                return(AionAuthResponse.BAN_ACCOUNT);
            }
            string text = client.IP.Split(':')[0];

            if (BannedIpController.IsBannedIp(text))
            {
                return(AionAuthResponse.BAN_IP);
            }
            if (!GameService.HahServerOnline())
            {
                return(AionAuthResponse.NOT_SERVER_ONLINE);
            }
            object @lock = _lock;

            ObjectFlowControl.CheckForSyncLockOnValueType(@lock);
            bool lockTaken = false;

            try
            {
                Monitor.Enter(@lock, ref lockTaken);
                if (GameService.ContainsAccount(account.Id))
                {
                    GameService.KickAccountFromGameServer(account.Id);
                    return(AionAuthResponse.ALREADY_LOGGED_IN);
                }
                if (accountOnLS.ContainsKey(account.Id))
                {
                    accountOnLS[account.Id].Disconnect();
                    accountOnLS.Remove(account.Id);
                    return(AionAuthResponse.ALREADY_LOGGED_IN);
                }
                client.Account = account;
                accountOnLS.Add(account.Id, client);
            }
            finally
            {
                if (lockTaken)
                {
                    Monitor.Exit(@lock);
                }
            }
            account.LastIp = text;
            account.AccountTime.LastLoginTime = DateAndTime.Now;
            AccountTimeController.UpDataLoginTime(account);
            return(AionAuthResponse.AUTHED);
        }