Move basic auth check

Backport of https://github.com/owncloud/core/pull/11130

@PVince81 @karlitschek 
Basically we return a cookie and redirect the response instead of writing a cookie but consider the user logged-in from the Basic Auth header. This will obviously not work with CLI tools and so on.

=> Unrelated from this => Will fix it in another PR.