mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
QgsCredentials: fix sip bindings
dbmanager: QgsCredentials is in core (fixes #8345)
This commit is contained in:
parent
5d3223127d
commit
aa7c428775
@ -8,7 +8,7 @@ class QgsCredentials
|
||||
//! virtual destructor
|
||||
virtual ~QgsCredentials();
|
||||
|
||||
bool get( QString realm, QString &username, QString &password, QString message = QString::null );
|
||||
bool get( QString realm, QString &username /In,Out/, QString &password /In,Out/, QString message = QString::null );
|
||||
void put( QString realm, QString username, QString password );
|
||||
|
||||
//! retrieves instance
|
||||
|
@ -34,6 +34,8 @@ except ImportError:
|
||||
|
||||
from ..html_elems import HtmlParagraph, HtmlList, HtmlTable
|
||||
|
||||
from qgis.core import QgsCredentials
|
||||
|
||||
|
||||
def classFactory():
|
||||
return PostGisDBPlugin
|
||||
@ -98,19 +100,10 @@ class PostGisDBPlugin(DBPlugin):
|
||||
except ConnectionError, e:
|
||||
err = str(e)
|
||||
|
||||
hasCredentialDlg = True
|
||||
try:
|
||||
from qgis.gui import QgsCredentials
|
||||
except ImportError: # no credential dialog
|
||||
hasCredentialDlg = False
|
||||
|
||||
# ask for valid credentials
|
||||
max_attempts = 3
|
||||
for i in range(max_attempts):
|
||||
if hasCredentialDlg:
|
||||
(ok, username, password) = QgsCredentials.instance().get(uri.connectionInfo(), username, password, err)
|
||||
else:
|
||||
(password, ok) = QInputDialog.getText(parent, self.tr("Enter password"), self.tr('Enter password for connection "%s":') % conn_name, QLineEdit.Password)
|
||||
(ok, username, password) = QgsCredentials.instance().get(uri.connectionInfo(), username, password, err)
|
||||
|
||||
if not ok:
|
||||
return False
|
||||
@ -128,8 +121,8 @@ class PostGisDBPlugin(DBPlugin):
|
||||
err = str(e)
|
||||
continue
|
||||
|
||||
if hasCredentialDlg:
|
||||
QgsCredentials.instance().put(uri.connectionInfo(), username, password)
|
||||
QgsCredentials.instance().put(uri.connectionInfo(), username, password)
|
||||
|
||||
return True
|
||||
|
||||
return False
|
||||
|
Loading…
x
Reference in New Issue
Block a user