notificationbox
This commit is contained in:
@@ -181,6 +181,10 @@ Item
|
|||||||
onAccepted: config.getRecoveryKey(getRecoveryDialog.currentFile, recpass)
|
onAccepted: config.getRecoveryKey(getRecoveryDialog.currentFile, recpass)
|
||||||
onRejected: quit()
|
onRejected: quit()
|
||||||
}
|
}
|
||||||
|
Notifications
|
||||||
|
{
|
||||||
|
id: oschkar
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted:
|
Component.onCompleted:
|
||||||
@@ -188,6 +192,7 @@ Item
|
|||||||
loggedin_user.loginOkay.connect(loggedin)
|
loggedin_user.loginOkay.connect(loggedin)
|
||||||
config.invalidEncryptionKey.connect(getEncryptionKey)
|
config.invalidEncryptionKey.connect(getEncryptionKey)
|
||||||
config.checkEncryptionKey()
|
config.checkEncryptionKey()
|
||||||
|
loggedin_user.noDbConnection.connect(dbConnectionFailed)
|
||||||
}
|
}
|
||||||
|
|
||||||
function loggedin()
|
function loggedin()
|
||||||
@@ -199,4 +204,10 @@ Item
|
|||||||
{
|
{
|
||||||
recoveryPaswordDialog.open()
|
recoveryPaswordDialog.open()
|
||||||
}
|
}
|
||||||
|
function dbConnectionFailed(msg)
|
||||||
|
{
|
||||||
|
oschkar.notificationBox.informativeText = msg
|
||||||
|
oschkar.notificationBox.text = "Verbindung zum Datenbankserver verloren"
|
||||||
|
oschkar.notificationBox.open()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,14 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
|
import QtQuick.Dialogs
|
||||||
|
|
||||||
Item {
|
Item
|
||||||
|
{
|
||||||
|
id: oschkar
|
||||||
|
property alias notificationBox: notificationDialog
|
||||||
|
MessageDialog
|
||||||
|
{
|
||||||
|
id: notificationDialog
|
||||||
|
buttons: MessageDialog.Ok
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,14 @@
|
|||||||
from .DbManager import DbManager
|
from .DbManager import DbManager
|
||||||
from ..PyqcrmFlags import PyqcrmFlags
|
from ..PyqcrmFlags import PyqcrmFlags
|
||||||
import mariadb
|
import mariadb
|
||||||
|
from PySide6.QtCore import QObject, Signal
|
||||||
|
|
||||||
class UserDAO:
|
class UserDAO(QObject):
|
||||||
|
noDbConnection = Signal(str)
|
||||||
__cursor = None
|
__cursor = None
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
#print(f"*** File: {__file__}, init()")
|
#print(f"*** File: {__file__}, init()")
|
||||||
|
super().__init__()
|
||||||
self.__con = DbManager().getConnection()
|
self.__con = DbManager().getConnection()
|
||||||
if self.__con:
|
if self.__con:
|
||||||
self.__cur = self.__con.cursor()
|
self.__cur = self.__con.cursor()
|
||||||
@@ -22,6 +25,7 @@ class UserDAO:
|
|||||||
print(f"Error: {e}")
|
print(f"Error: {e}")
|
||||||
print(e.errno)
|
print(e.errno)
|
||||||
user_created = False
|
user_created = False
|
||||||
|
self.noDbConnection.emit(str(e))
|
||||||
finally:
|
finally:
|
||||||
return user_created
|
return user_created
|
||||||
|
|
||||||
@@ -34,6 +38,7 @@ class UserDAO:
|
|||||||
return None
|
return None
|
||||||
except mariadb.Error as e:
|
except mariadb.Error as e:
|
||||||
print(str(e))
|
print(str(e))
|
||||||
|
self.noDbConnection.emit(str(e))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,10 +9,13 @@ from PySide6.QtCore import Slot, QObject, Signal, QUrl
|
|||||||
class UserManager(QObject):
|
class UserManager(QObject):
|
||||||
|
|
||||||
loginOkay = Signal()
|
loginOkay = Signal()
|
||||||
|
noDbConnection = Signal(str)
|
||||||
|
|
||||||
def __init__(self, user_config = None, role = None):
|
def __init__(self, user_config = None, role = None):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.__con = DbManager().getConnection()
|
self.__con = DbManager().getConnection()
|
||||||
|
self.__user_dao = UserDAO()
|
||||||
|
self.__user_dao.noDbConnection.connect(self.noDbConnection)
|
||||||
if self.__con:
|
if self.__con:
|
||||||
self.__cur = self.__con.cursor()
|
self.__cur = self.__con.cursor()
|
||||||
if user_config and role:
|
if user_config and role:
|
||||||
@@ -25,7 +28,7 @@ class UserManager(QObject):
|
|||||||
|
|
||||||
def createUser(self):
|
def createUser(self):
|
||||||
self.__hashPassword()
|
self.__hashPassword()
|
||||||
user_created = UserDAO().createUser(self.__username, self.__password, self.__info, self.__role)
|
user_created = self.__user_dao.createUser(self.__username, self.__password, self.__info, self.__role)
|
||||||
|
|
||||||
return user_created
|
return user_created
|
||||||
|
|
||||||
@@ -54,7 +57,7 @@ class UserManager(QObject):
|
|||||||
|
|
||||||
@Slot(str, str)
|
@Slot(str, str)
|
||||||
def login(self, username, password):
|
def login(self, username, password):
|
||||||
user = UserDAO().getUser(username)
|
user = self.__user_dao.getUser(username)
|
||||||
if user:
|
if user:
|
||||||
self.__checkPassword(password, user[2])
|
self.__checkPassword(password, user[2])
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user