Skip to content

Commit b5d49ff

Browse files
committed
fix get_layers_auth_ids
1 parent ad2afb8 commit b5d49ff

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Mergin/utils_auth.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
QgsExpressionContextUtils,
2121
Qgis,
2222
QgsProject,
23-
QgsDataSourceUri,
23+
QgsProviderRegistry,
2424
)
2525
from qgis.PyQt.QtCore import QSettings, QUrl
2626
from qgis.PyQt.QtNetwork import QNetworkRequest
@@ -582,11 +582,14 @@ def __init__(self, qgis_file=None):
582582
def get_layers_auth_ids(self) -> list[str]:
583583
"""Get the auth config IDs of the protected layers in the current project."""
584584
auth_ids = set()
585+
reg = QgsProviderRegistry.instance()
585586
for layer in self.project.mapLayers().values():
586587
source = layer.source()
587-
uri = QgsDataSourceUri(source)
588-
if uri.authConfigId():
589-
auth_ids.add(uri.authConfigId())
588+
prov_type = layer.providerType()
589+
decoded_uri = reg.decodeUri(prov_type, source)
590+
auth_id = decoded_uri.get("authcfg")
591+
if auth_id:
592+
auth_ids.add(auth_id)
590593
return list(auth_ids)
591594

592595
def get_auth_config_hash(self, auth_ids: list[str]) -> str:

0 commit comments

Comments
 (0)