Fixed logout issue, factored out require_privileges