Simplize missing auth check. #857
Introduce is_valid_request() and fixed bug with logging always executing. #857