quick fix
This commit is contained in:
@@ -20,7 +20,7 @@ namespace Server
|
|||||||
private SaveData saveData;
|
private SaveData saveData;
|
||||||
private string username = null;
|
private string username = null;
|
||||||
private DateTime sessionStart;
|
private DateTime sessionStart;
|
||||||
private const string fileName = "userInfo.dat";
|
private string fileName;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -32,6 +32,7 @@ namespace Server
|
|||||||
this.communication = communication;
|
this.communication = communication;
|
||||||
this.tcpClient = tcpClient;
|
this.tcpClient = tcpClient;
|
||||||
this.stream = this.tcpClient.GetStream();
|
this.stream = this.tcpClient.GetStream();
|
||||||
|
this.fileName = Directory.GetCurrentDirectory() + "/userInfo.dat";
|
||||||
stream.BeginRead(buffer, 0, buffer.Length, new AsyncCallback(OnRead), null);
|
stream.BeginRead(buffer, 0, buffer.Length, new AsyncCallback(OnRead), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,7 +138,7 @@ namespace Server
|
|||||||
|
|
||||||
Array.Copy(message, 5, payloadbytes, 0, message.Length - 5);
|
Array.Copy(message, 5, payloadbytes, 0, message.Length - 5);
|
||||||
dynamic json = JsonConvert.DeserializeObject(Encoding.ASCII.GetString(payloadbytes));
|
dynamic json = JsonConvert.DeserializeObject(Encoding.ASCII.GetString(payloadbytes));
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (DataParser.isRawData(message))
|
else if (DataParser.isRawData(message))
|
||||||
{
|
{
|
||||||
@@ -167,8 +168,8 @@ namespace Server
|
|||||||
private bool verifyLogin(string username, string password)
|
private bool verifyLogin(string username, string password)
|
||||||
{
|
{
|
||||||
Console.WriteLine("got hashes " + username + "\n" + password);
|
Console.WriteLine("got hashes " + username + "\n" + password);
|
||||||
|
|
||||||
|
|
||||||
if (!File.Exists(fileName))
|
if (!File.Exists(fileName))
|
||||||
{
|
{
|
||||||
File.Create(fileName);
|
File.Create(fileName);
|
||||||
@@ -176,7 +177,8 @@ namespace Server
|
|||||||
newUsers(username, password);
|
newUsers(username, password);
|
||||||
Console.WriteLine("true");
|
Console.WriteLine("true");
|
||||||
return true;
|
return true;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
Console.WriteLine("file exists, located at " + Path.GetFullPath(fileName));
|
Console.WriteLine("file exists, located at " + Path.GetFullPath(fileName));
|
||||||
string[] usernamesPasswords = File.ReadAllLines(fileName);
|
string[] usernamesPasswords = File.ReadAllLines(fileName);
|
||||||
@@ -206,7 +208,7 @@ namespace Server
|
|||||||
|
|
||||||
private void newUsers(string username, string password)
|
private void newUsers(string username, string password)
|
||||||
{
|
{
|
||||||
|
|
||||||
Console.WriteLine("creating new entry in file");
|
Console.WriteLine("creating new entry in file");
|
||||||
using (StreamWriter sw = File.AppendText(fileName))
|
using (StreamWriter sw = File.AppendText(fileName))
|
||||||
{
|
{
|
||||||
@@ -216,7 +218,7 @@ namespace Server
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static string ByteArrayToString(byte[] ba)
|
public static string ByteArrayToString(byte[] ba)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user