public static DbUser VerifyLogin(RequestContext request, NetworkStream stream) { string tempUsername = request.GetUsernameFromDict(); //überprüfung, ob der Token passd if (!(CheckToken(tempUsername))) { return(null); } string username = ""; string[] tempToken = tempUsername.Split(new char[] { '_' }); //falls auch _ im usernamen drinnen sind for (int i = 0; i < tempToken.Length - 1; i++) { username += tempToken[i]; } DbUser user = mysql.GetOneUser(username); //erstellt ein DB User objekt Console.WriteLine(user.userName); if (request.GetPwdFromDict() == user.pwd) { string message = "Succsessful"; ServerClientConnection.SendData(stream, message); return(user); } Console.WriteLine("Wrong user or Pwd!"); return(null); }
public static bool RegisterAtDb(RequestContext request, NetworkStream stream) { ServerDbConnection mysql = new ServerDbConnection(); //check if username already taken if ((mysql.GetOneUser(request.GetUsernameFromDict()).userName != null)) { //wenns den user bereits gibt Console.WriteLine("Wrong username"); return(false); } //chek if email already taken bool isValidEmail = ValidEmail(request.GetEmailFromDict()); if (!((mysql.GetOneUser(request.GetUsernameFromDict()).email == null) && (isValidEmail == true))) { //wenns die email ned okay ist Console.WriteLine("Wrong email!"); return(false); } //Query statement bilden string query = MakeRegisterQuery(request); //var temp = new ServerDbCOnnection(); bool succsess = mysql.VerifyRegister(query); if (succsess == true) { Console.WriteLine("You are registered"); } else { Console.WriteLine("Error by executing Databas Conn"); return(false); } return(true); }