Move basic auth check

Backport of https://github.com/owncloud/core/pull/11130

@PVince81 @karlitschek 
Ok - I thought I found what the bug was. God this is a horrible base.php madness... Let me dig into this...