Hi there and I'm sorry you've been having these issues with your cat.
With regards the biting when she wants the door opened, it sounds like she has learned that this gets her what she wants.
So, if she is being ignored and the door is not opening, she knows that escalating things earns attention and (possible?) the door gets opened.
In this scenario, we need to open the door at certain times, not when she asks. Being consistent should create a routine. If she bites, the door does not get opened.
With regards biting when she was just being loving, this is probably something called 'petting induced aggression'.
This is actually not as uncommon as you may think and is a reason that many owners will seek assistance. This is particularly true of cats that are rescues or were feral or semi-feral as they often did not receive adequate socialisation and integration with humans when they were in their key developmental stages in their first couple of months of life. While the best time for them to learn to socialise correctly with humans is when they are kittens, this does not mean that they are beyond help and there are certainly things what can be done.
When it happens, the cats are feeling very comfortable, are perhaps purring and enjoying a head scratch. They are really relaxed and suddenly, for no apparent reason, they put their guard up and may hiss, bite, scratch or run away. The theory is that they have suddenly realised that they have let their guard down and feel vulnerable so quickly act offensively in fear of something bad happening. It's sad really, that they can not just enjoy being content but feel that something bad may happen.
Our aim is to minimise and eventually eliminate these events.
Be sure you are reading her body language. At the first sense of a bite coming on, remove yourself from the situation. Watch for ears down, freezing, tail wagging etc. Some cats give lots of clues, while others do not.
Ideally, you would see a pattern to her behaviour e.g. she will tolerate petting for 5 minutes and then becomes impatient. Try to pre-empt him and stop a petting/cuddle session after 4 minutes. If she has been really good the whole time, reward her with vocal praise and a treat. Of course, if the session ends badly, she gets no praise or treat.
It is useful in these situations to build her confidence and sense of security so she feels less inclined to lash out. This is done by enriching her environment with interactive toys such as laser pointers and battery operated mice, as well as food puzzles, cat mazes and cat trees. Some cats also enjoy catnip toys. Be cautious to not use your hand to play at any time, as this can increasing hand biting tendencies.
Another consideration would be stress-reducing products such as calming supplements in her food each day (e.g. nutracalm or Yucalm) as well as a Feliway plug-in.