Move BasicAuth check to isLoggedIn

Ensures that Basic Auth works properly for APIs and removes the need for some even uglier lines of code.

Related to https://github.com/owncloud/core/pull/11155#discussion_r17724967 and needs a backport to stable7.

@PVince81 @DeepDiver1975 @karlitschek Testing welcome. Especially the APIs (e.g. `curl -D - http://admin:admin@localhost/core/index.php/apps/files/api/v1/thumbnail/100/100/welcome.txt`) and https://github.com/owncloud/core/issues/11129