mla157 / Project-Finder

Finder
2 stars 1 forks source link

Zwei Abfragen mit einer DatabaseConnection brechen ab #8

Closed mla157 closed 6 years ago

mla157 commented 6 years ago

Ich brauche zwei "DatabaseConnections" wenn ich nur eine benutze gibt es eine Exception.

            //INSECURE!
            var databaseConnection = new DatabaseConnection();
            var seconddatabaseConnection = new DatabaseConnection();

            var queryUser = databaseConnection.GetData($"SELECT * FROM user WHERE benutzername = '" + user.userName +"'");

            if (queryUser.Count > 0)
            {
                return this.Request.CreateResponse(HttpStatusCode.InternalServerError);
            }

            try
            {
                seconddatabaseConnection.QueryInsert($"INSERT INTO user (`benutzername`, `vorname`, `nachname`, `passwort`) VALUES (\'{user.userName}\', \'{user.firstName}\' , \'{user.lastName}\', \'{user.password}\')");
            }
            catch (Exception e)
            {
                return this.Request.CreateResponse(HttpStatusCode.InternalServerError);
            }