That is not a bug, but you are not the first person that got tripped up by that and it looks like you got a rather unsportsmanlike opponent.
When you have to make a decision in the game (usually your turn, or when you need to decide what to discard for Militia, etc.) there is a 4 min clock ticking for you. If that time is over and you did not make a decision, your opponents get the option to make you resign the game. That is to prevent a game being stuck for a long time if a player loses internet connection, or simply walks away from a clearly lost game.
You asking for an undo does not constitute you transfering that 4 min clock to your opponent, it's still ticking for you. Doing it otherwise would not work, unscrupulous players (of which there are unfortunately too many) would simply make an undo request, get it denied, then wait 3m 30s for doing another undo request, get it denied, then wait ...
So this is what happened to you, from your description. Your opponent waited until the 4 min where over, they got the option to make you resign, and used it.
The gist of this is that if you are playing against an unknown opponent, assume your undo effectively denied after say 2-3 min, if there is no communication (same players ask what the undo is about). Then I would cancel the undo request and play on.