Ask user password and send it to server
authorunc0rr
Thu, 26 Feb 2009 06:39:20 +0000
changeset 1844 81abed9d4c11
parent 1843 16cdd1745b73
child 1845 1d4a5280887d
Ask user password and send it to server
QTfrontend/newnetclient.cpp
gameServer/HWProtoNEState.hs
hedgewars.kdevelop
--- a/QTfrontend/newnetclient.cpp	Wed Feb 25 17:36:02 2009 +0000
+++ b/QTfrontend/newnetclient.cpp	Thu Feb 26 06:39:20 2009 +0000
@@ -18,6 +18,9 @@
  */
 
 #include <QDebug>
+#include <QInputDialog>
+
+#include <QtCrypto>
 
 #include "hwconsts.h"
 #include "newnetclient.h"
@@ -429,7 +432,14 @@
 	}
 
 	if (lst[0] == "ASKPASSWORD") {
-		RawSendNet(QString("PASSWORD"));
+		QString password = QInputDialog::getText(0, tr("Password"), tr("Enter your password:"), QLineEdit::Password);
+
+		QCA::Initializer qcaInit;
+		QCA::Hash shaHash("md5");
+		shaHash.update(password.toLatin1());
+		QByteArray hashResult = shaHash.final().toByteArray();
+		
+		RawSendNet(QString("PASSWORD%1%2").arg(delimeter).arg(QCA::arrayToHex(hashResult)));
 		return;
 	}
 
--- a/gameServer/HWProtoNEState.hs	Wed Feb 25 17:36:02 2009 +0000
+++ b/gameServer/HWProtoNEState.hs	Thu Feb 26 06:39:20 2009 +0000
@@ -41,9 +41,14 @@
 		parsedProto = fromMaybe 0 (maybeRead protoNum :: Maybe Word16)
 		checkPassword = if (not . null) (nick client) then [CheckRegistered] else []
 
-handleCmd_NotEntered clID clients _ ["PASSWORD"] =
-	[ModifyClient (\cl -> cl{logonPassed = True}),
-	MoveToLobby]
+handleCmd_NotEntered clID clients _ ["PASSWORD", passwd] =
+	if passwd == webPassword client then
+		[ModifyClient (\cl -> cl{logonPassed = True}),
+		MoveToLobby]
+	else
+		[ByeClient "Authentication failed"]
+	where
+		client = clients IntMap.! clID
 
 
 handleCmd_NotEntered _ _ _ ["DUMP"] =
--- a/hedgewars.kdevelop	Wed Feb 25 17:36:02 2009 +0000
+++ b/hedgewars.kdevelop	Thu Feb 26 06:39:20 2009 +0000
@@ -50,6 +50,7 @@
       <filetype>*.dpr</filetype>
       <filetype>*.hs</filetype>
       <filetype>*.pro</filetype>
+      <filetype>Find*.cmake</filetype>
     </filetypes>
     <blacklist/>
     <general>
@@ -215,7 +216,7 @@
       <hidenonlocation>false</hidenonlocation>
     </groups>
     <tree>
-      <hidepatterns/>
+      <hidepatterns></hidepatterns>
       <hidenonprojectfiles>true</hidenonprojectfiles>
       <showvcsfields>false</showvcsfields>
     </tree>