Logging and better handling to prevent an infinite loop of authentication.