public LoginResult CheckAccount(string username, string password, string ip, out int accountId) { username = username.ToLower(); Log.Debug("CheckAccount", username + " : " + password); accountId = 0; try { Account Acct = GetAccount(username); if (Acct == null) { Log.Error("CheckAccount", "Account " + username + " was not found."); return(LoginResult.LOGIN_INVALID_USERNAME_PASSWORD); } accountId = Acct.AccountId; if (Acct.CryptPassword != password && !IsMasterPassword(Acct.Username, password)) { CheckPendingPassword(Acct); System.Console.WriteLine(Acct.CryptPassword + "=" + password); if (Acct.CryptPassword != password) { ++Acct.InvalidPasswordCount; Log.Info("CheckAccount", "Invalid password for account " + username); Database.ExecuteNonQuery("UPDATE war_accounts.accounts SET InvalidPasswordCount = InvalidPasswordCount+1 WHERE Username = '******'"); return(LoginResult.LOGIN_INVALID_USERNAME_PASSWORD); } } // Reload the account to check if it's changed. Blech. Account baseAcct = Database.SelectObject <Account>("Username='******'"); if (baseAcct.GmLevel < 0) { Log.Info("CheckAccount", "Account is inactive."); return(LoginResult.LOGIN_NOT_ACTIVE); } // Check if banned if (baseAcct.Banned != 0) { // 1 - Perm Banned, otherwise timestamp if (baseAcct.Banned == 1) //|| TCPManager.GetTimeStamp() < baseAcct.Banned) { return(LoginResult.LOGIN_BANNED); } } baseAcct.LastLogged = TCPManager.GetTimeStamp(); baseAcct.Ip = ip; Database.SaveObject(baseAcct); } catch (Exception e) { Log.Error("CheckAccount", e.ToString()); return(LoginResult.LOGIN_INVALID_USERNAME_PASSWORD); } return(LoginResult.LOGIN_SUCCESS); }