# HG changeset patch # User unc0rr # Date 1235764282 0 # Node ID 2178c0fc838ce86da63058c74597232df09204db # Parent 24d0074d4eeda2915441ed086cadc4b68d33022d Set admin flag and send admin notification to users with rid equal to 3 diff -r 24d0074d4eed -r 2178c0fc838c gameServer/Actions.hs --- a/gameServer/Actions.hs Thu Feb 26 15:00:48 2009 +0000 +++ b/gameServer/Actions.hs Fri Feb 27 19:51:22 2009 +0000 @@ -259,10 +259,10 @@ processAction (clID, serverInfo, clients, rooms) (ProcessAccountInfo info) = do case info of - HasAccount passwd -> do + HasAccount passwd isAdmin -> do infoM "Clients" $ show clID ++ " has account" writeChan (sendChan $ clients ! clID) ["ASKPASSWORD"] - return (clID, serverInfo, adjust (\cl -> cl{webPassword = passwd}) clID clients, rooms) + return (clID, serverInfo, adjust (\cl -> cl{webPassword = passwd, isAdministrator = isAdmin}) clID clients, rooms) Guest -> do infoM "Clients" $ show clID ++ " is guest" processAction (clID, serverInfo, adjust (\cl -> cl{logonPassed = True}) clID clients, rooms) MoveToLobby diff -r 24d0074d4eed -r 2178c0fc838c gameServer/CoreTypes.hs --- a/gameServer/CoreTypes.hs Thu Feb 26 15:00:48 2009 +0000 +++ b/gameServer/CoreTypes.hs Fri Feb 27 19:51:22 2009 +0000 @@ -25,6 +25,7 @@ roomID :: Int, isMaster :: Bool, isReady :: Bool, + isAdministrator :: Bool, forceQuit :: Bool, partRoom :: Bool } @@ -139,7 +140,7 @@ ) data AccountInfo = - HasAccount String + HasAccount String Bool | Guest data CoreMessage = @@ -151,7 +152,6 @@ data DBQuery = CheckAccount Int String - | CheckPassword String type Clients = IntMap.IntMap ClientInfo diff -r 24d0074d4eed -r 2178c0fc838c gameServer/HWProtoNEState.hs --- a/gameServer/HWProtoNEState.hs Thu Feb 26 15:00:48 2009 +0000 +++ b/gameServer/HWProtoNEState.hs Fri Feb 27 19:51:22 2009 +0000 @@ -44,11 +44,12 @@ handleCmd_NotEntered clID clients _ ["PASSWORD", passwd] = if passwd == webPassword client then [ModifyClient (\cl -> cl{logonPassed = True}), - MoveToLobby] + MoveToLobby] ++ adminNotice else [ByeClient "Authentication failed"] where client = clients IntMap.! clID + adminNotice = if isAdministrator client then [AnswerThisClient ["ADMIN_ACCESS"]] else [] handleCmd_NotEntered _ _ _ ["DUMP"] = diff -r 24d0074d4eed -r 2178c0fc838c gameServer/NetRoutines.hs --- a/gameServer/NetRoutines.hs Thu Feb 26 15:00:48 2009 +0000 +++ b/gameServer/NetRoutines.hs Fri Feb 27 19:51:22 2009 +0000 @@ -48,7 +48,9 @@ False False False - False) + False + False + ) writeChan coreChan $ Accept newClient diff -r 24d0074d4eed -r 2178c0fc838c gameServer/OfficialServer/DBInteraction.hs --- a/gameServer/OfficialServer/DBInteraction.hs Thu Feb 26 15:00:48 2009 +0000 +++ b/gameServer/OfficialServer/DBInteraction.hs Fri Feb 27 19:51:22 2009 +0000 @@ -24,23 +24,28 @@ -- to be deleted -------------------------------------------------- ------------------------------------------------------------------- +dbQueryString = + "SELECT users.pass, users_roles.rid FROM `users`, users_roles " + ++ "WHERE users.name = ? AND users_roles.uid = users.uid" dbInteractionLoop queries coreChan dbConn = do q <- readChan queries case q of CheckAccount clID name -> do - statement <- prepare dbConn "SELECT pass FROM users WHERE name=?" + statement <- prepare dbConn dbQueryString execute statement [SqlString name] - pass <- fetchRow statement + passAndRole <- fetchRow statement finish statement - if isJust pass then - writeChan coreChan $ ClientAccountInfo clID (HasAccount $ fromSql $ head $ fromJust $ pass) + if isJust passAndRole then + writeChan coreChan $ + ClientAccountInfo clID $ + HasAccount + (fromSql $ head $ fromJust $ passAndRole) + ((fromSql $ last $ fromJust $ passAndRole) == (3 :: Int)) else writeChan coreChan $ ClientAccountInfo clID Guest `onException` (unGetChan queries $ CheckAccount clID name) - - CheckPassword queryStr -> putStrLn queryStr dbInteractionLoop queries coreChan dbConn