Move basic auth check

Backport of https://github.com/owncloud/core/pull/11130