The rules don't say, thus it is up to the DM
Thaumaturgy only has this to say about the door closing effect:
You instantaneously cause an unlocked door or window to fly open or slam shut.
Now, 5e spells are designed to do only the things that they say in the spell description. However, in this case, that doesn't really help settle the dilemma. Does the door shut, regardless of obstacles because the spell says that the door shuts? Or will obstacles prevent the door from shutting because there is nothing to indicate that the door slamming shut is in any way immune to the effects of normal physics with respect to things blocking it?
The thing is, the rules don't say. And either ruling, when applied uniformly, can lead to nonsensical results. For example, the door flinging enormous boulders out of the way to close.
And that is another thing 5e spells are designed for. Many spells are written in language that purposefully doesn't try to cover every detail or circumstance instead choosing to leave it up to the DM to adjudicate the results in those cases.
This is one of those cases. Ask your DM.
Reasonable ruling: it acts like a normal door slammed by a normal person
The way I would rule it at my table is that the door is not imbued with any kind of supernatural strength, but instead is simply closed as if I had slammed it myself.
So, what would happen to the guy in the door? It would depend on the exact circumstances of where they where, but if they were in enough to block the door, likely the only thing it would do to them is stub their toe or bruise their nose (not enough to do HP damage) just as a normal slammed door would do and the door would remain ajar.
This is my ruling that I would probably make a my table. It makes sense to me because we all know how doors normally work and thus it makes it easy to keep my rulings consistent and reasonable.
Your DM should consider what option is best fit for their table that will make sense to them and maximise fun.