Haven't completely thought this through but...
Might be possible to have kind of an 'airlock' system.
Basically, there would be a first door that opens for anyone, but when it closes, it turns on some team triggers that will close the second door if the incorrect team is found inside the chamber, also opening the first door to let them out. If the incorrect team is not found in the chamber, then the second door never closes, and a timer will open the first door after some time to reset everything.
The 'airlock' takes care of the possibility of members of opposite teams going through a team-triggered door at the same time.
Might have to actually make this to see if its possible. And even so it might be complicated enough that it would get broken after extended use online...
And now I realize I only thought this through for one direction, hmmm