Move basic auth login out of `isLoggedIn`

Potentially fixes https://github.com/owncloud/core/issues/12915 and opens the door for potential other bugs...

Please test very carefully, this includes:

- Testing from OCS via cURL (as in #12915)
- Testing from OCS via browser (Open the "Von Dir geteilt" shares overview)
- WebDAV
- CalDAV
- CardDAV
Store result of authentication
Check basic auth header only for not-logged-in users
Merge pull request #12917 from owncloud/fix-ocs-12915-api

Move basic auth login out of `isLoggedIn`