gameServer/OfficialServer/DBInteraction.hs
changeset 1847 2178c0fc838c
parent 1841 fba7210b438b
child 1857 b835395659e2
--- 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