/// <summary> /// Disables the user DA uth. /// </summary> /// <returns>The user DA uth.</returns> /// <param name="plfUser">Plf user.</param> public static ServerPacketConfirmation DisableUserDAuth(PLFUser plfUser) { ClientPacketDisableDAuth clientPacketDisableDAuth = new ClientPacketDisableDAuth(plfUser); ServerPacketConfirmation serverPacketConfirmation = TCPClient.SendPacket(clientPacketDisableDAuth) as ServerPacketConfirmation; if (serverPacketConfirmation == null) { return(new ServerPacketConfirmation(false, NetworkError.SERVER_UNAVAILABLE)); } return(serverPacketConfirmation); }
public override Packet OnPacketReceive(Packet receivedPacket) { //get received packet ClientPacketDisableDAuth clientPacketDisableDAuth = receivedPacket as ClientPacketDisableDAuth; ConsoleHelper.Write("Receive - ClientPacketDisableDAuth"); //read packet infos PLFUser user = clientPacketDisableDAuth.PlfUser; //insert key in db command MySqlCommand disableDAuthCommand = new MySqlCommand(); disableDAuthCommand.Connection = Program.mySQLManager.MySQLConnection.MysqlConnection; disableDAuthCommand.CommandText = $"DELETE FROM `T_DoubleAuth` WHERE `daUserID`='{user.ID}'"; ServerPacketConfirmation serverPacketConfirmation; try { //execute command disableDAuthCommand.ExecuteNonQuery(); serverPacketConfirmation = new ServerPacketConfirmation(true, NetworkError.NONE); //run on extern thread new Thread(() => { Program.mailManager.SendMail(user.UserEMail, "PET LA FORME - Double Authentification", $"Bonjour {user.UserName}! La double authentification a bien été désactivée sur votre compte. "); } ).Start(); } catch (Exception e) { serverPacketConfirmation = new ServerPacketConfirmation(false, NetworkError.GLOBAL_UNKNOWN); Console.WriteLine(e.Message); } ConsoleHelper.Write("Send - ServerPacketConfirmation"); return(serverPacketConfirmation); }