Пример #1
0
        public static string isRegisterValid(string user, string pass)
        {
            Logger.WriteLine(LogState.Info, "Checking Registration: " + user);

            if (DbQuerys.InsertAccountData(user, pass, "*****@*****.**", 1, "20001", true, 0, 0, "127.0.0.1", "0", false, false, 0, Convert.ToInt64(DateTime.Now.Ticks)))
            {
                return(OpCode.RegisterPacket_Register_Account_CREATED.GetHashCode().ToString());
            }
            return(OpCode.RegisterPacket_Register_Account_EXIST.GetHashCode().ToString());
        }
Пример #2
0
        public static string isLoginValid(string user, string pass)
        {
            Account Account = new Account();

            Account = DbQuerys.GetAccountData(user, pass);

            if (Account == null)
            {
                return(OpCode.LoginPacket_Auth_INVALID_PASSWORD.GetHashCode().ToString());
            }
            else
            {
                Logger.WriteLine(LogState.Debug, "Checking Account: " + Account.Username);
                //BANN CHECK
                if (Account.IsBanned)
                {
                    Logger.WriteLine(LogState.Debug, "Account.IsBanned: " + Account.Username);
                    Logger.WriteLine(LogState.Debug, "Account.UnBanDate: " + Account.UnBanDate);

                    Int64 timeStampNowValue    = Convert.ToInt64(DateTime.Now.Ticks);
                    Int64 timeStampUnbannValue = Account.UnBanDate;
                    Logger.WriteLine(LogState.Debug, "timeStampNowValue: '" + timeStampNowValue + "' !");
                    Logger.WriteLine(LogState.Debug, "timeStampUnbannValue: '" + timeStampUnbannValue + "' !");

                    //Unban Account if Time Ok!
                    if (timeStampUnbannValue <= timeStampNowValue)
                    {
                        DbQuerys.SetBanStatus(user, false, 0);
                        return(OpCode.LoginPacket_Auth_UNBANNED.GetHashCode().ToString());
                    }

                    //BANNED
                    Account = null;
                    return(OpCode.LoginPacket_Auth_BANNED.GetHashCode().ToString());
                }

                if (Account.IsOnline)
                {
                    Logger.WriteLine(LogState.Info, "Account: " + Account.Username + " already logged in!");
                    //DbQuerys.SetIsOnline(user, false); //this for later setting offline kicking other player maybe... for now no 2nd login possible!
                    Account = null;
                    return(OpCode.LoginPacket_Auth_ONLINE.GetHashCode().ToString());
                }

                //AuthorizationSuccessfull
                Logger.WriteLine(LogState.Info, "Account Verification for, " + Account.Username + " Ok!");
                DbQuerys.SetLastOnlineUtc(Account.Username);
                return(OpCode.LoginPacket_Auth_OK.GetHashCode().ToString());
            }
        }