Move basic auth check

Backport of https://github.com/owncloud/core/pull/11130

@PVince81 @karlitschek 
wait this was living here for a long time on purpose - @tanghus would have known why