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