From: Milan Crha <mcrha@redhat.com>
Date: Fri, 19 Mar 2021 09:33:50 +0100
Subject: EWebDAVCollectionBackend: Preset also auth method on the new child

The new child inherits the SSL trust setting, but it should inherit
also the authentication method, thus it can use the collection
source as the authentication source, thus sharing the credentials.
As it's done only for the new children, they can still have this
overwritten later.

(cherry picked from commit 55fc226f7076db61e63f2c7598316d75e7ba51a4)
---
 src/libebackend/e-webdav-collection-backend.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/libebackend/e-webdav-collection-backend.c b/src/libebackend/e-webdav-collection-backend.c
index 7f31652..63ce00c 100644
--- a/src/libebackend/e-webdav-collection-backend.c
+++ b/src/libebackend/e-webdav-collection-backend.c
@@ -162,15 +162,16 @@ webdav_collection_add_found_source (ECollectionBackend *collection,
 	}
 
 	if (source) {
-		ESource *master_source;
+		ESource *collection_source;
 		ESourceCollection *collection_extension;
-		ESourceAuthentication *child_auth;
+		ESourceAuthentication *collection_auth, *child_auth;
 		ESourceResource *resource;
-		ESourceWebdav *master_webdav, *child_webdav;
+		ESourceWebdav *collection_webdav, *child_webdav;
 
-		master_source = e_backend_get_source (E_BACKEND (collection));
-		master_webdav = e_source_get_extension (master_source, E_SOURCE_EXTENSION_WEBDAV_BACKEND);
-		collection_extension = e_source_get_extension (master_source, E_SOURCE_EXTENSION_COLLECTION);
+		collection_source = e_backend_get_source (E_BACKEND (collection));
+		collection_auth = e_source_get_extension (collection_source, E_SOURCE_EXTENSION_AUTHENTICATION);
+		collection_webdav = e_source_get_extension (collection_source, E_SOURCE_EXTENSION_WEBDAV_BACKEND);
+		collection_extension = e_source_get_extension (collection_source, E_SOURCE_EXTENSION_COLLECTION);
 		child_auth = e_source_get_extension (source, E_SOURCE_EXTENSION_AUTHENTICATION);
 		child_webdav = e_source_get_extension (source, E_SOURCE_EXTENSION_WEBDAV_BACKEND);
 		resource = e_source_get_extension (source, E_SOURCE_EXTENSION_RESOURCE);
@@ -182,8 +183,9 @@ webdav_collection_add_found_source (ECollectionBackend *collection,
 		e_source_resource_set_identity (resource, identity);
 
 		if (is_new) {
-			/* inherit ssl trust options */
-			e_source_webdav_set_ssl_trust (child_webdav, e_source_webdav_get_ssl_trust (master_webdav));
+			/* inherit common settings */
+			e_source_webdav_set_ssl_trust (child_webdav, e_source_webdav_get_ssl_trust (collection_webdav));
+			e_source_authentication_set_method (child_auth, e_source_authentication_get_method (collection_auth));
 		}
 	}
 
