implemented encyption
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import sqlite3
|
||||
|
||||
from services.encryption import Encryption
|
||||
|
||||
class Log:
|
||||
def __init__(self, connection : sqlite3.Connection, id = None, username = None, date = None, time = None, description = None, additional_information = None, suspicious = None):
|
||||
@@ -26,26 +26,11 @@ class Log:
|
||||
|
||||
def save(self):
|
||||
cur = self.connection.cursor()
|
||||
|
||||
cur.execute("""
|
||||
INSERT INTO logs
|
||||
(id, username, date, time, description, additional_information, suspicious) VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||
""", (self.id, self.username, self.date, self.time, self.description, self.additional_information, self.suspicious))
|
||||
|
||||
self.connection.commit()
|
||||
cur.close()
|
||||
return True
|
||||
|
||||
def update(self):
|
||||
cur = self.connection.cursor()
|
||||
cur.execute("""
|
||||
UPDATE logs SET
|
||||
username = ?,
|
||||
date = ?,
|
||||
description = ?,
|
||||
additional_information = ?,
|
||||
suspicious = ?
|
||||
WHERE id = ?
|
||||
""", (self.firstname, self.lastname, self.zipcode, self.city_id, self.email, self.phone, self.password, self.role, self.id))
|
||||
""", (self.id, Encryption.encrypt(self.username), Encryption.encrypt(self.date), Encryption.encrypt(self.time), Encryption.encrypt(self.description), Encryption.encrypt(self.additional_information), self.suspicious))
|
||||
|
||||
self.connection.commit()
|
||||
cur.close()
|
||||
@@ -60,10 +45,10 @@ class Log:
|
||||
|
||||
def _set_row_values(self, row):
|
||||
self.id = row[0]
|
||||
self.username = row[1]
|
||||
self.date = row[2]
|
||||
self.time = row[3]
|
||||
self.description = row[4]
|
||||
self.additional_information = row[5]
|
||||
self.username = Encryption.decrypt(row[1])
|
||||
self.date = Encryption.decrypt(row[2])
|
||||
self.time = Encryption.decrypt(row[3])
|
||||
self.description = Encryption.decrypt(row[4])
|
||||
self.additional_information = Encryption.decrypt(row[5])
|
||||
self.suspicious = row[6]
|
||||
return self
|
@@ -1,5 +1,6 @@
|
||||
import sqlite3
|
||||
from datetime import datetime
|
||||
from services.encryption import Encryption
|
||||
|
||||
class User:
|
||||
def __init__(self, connection : sqlite3.Connection, id = None, username = None, firstname = None, lastname = None, address = None, zipcode = None, city_id = None, email = None, phone = None, password = None, role = None):
|
||||
@@ -46,7 +47,7 @@ class User:
|
||||
cur.execute("""
|
||||
INSERT INTO users
|
||||
(id, username, firstname, lastname, address, zipcode, city_id, email, phone, password, role, created) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""", (self.id, self.username, self.firstname, self.lastname, self.address, self.zipcode, self.city_id, self.email, self.phone, self.password, self.role, current_date))
|
||||
""", (self.id, Encryption.encrypt(self.username), Encryption.encrypt(self.firstname), Encryption.encrypt(self.lastname), Encryption.encrypt(self.address), Encryption.encrypt(self.zipcode), self.city_id, Encryption.encrypt(self.email), Encryption.encrypt(self.phone), Encryption.encrypt(self.password), Encryption.encrypt(self.role), current_date))
|
||||
|
||||
self.connection.commit()
|
||||
cur.close()
|
||||
@@ -67,7 +68,7 @@ class User:
|
||||
password = ?,
|
||||
role = ?
|
||||
WHERE id = ?
|
||||
""", (self.username, self.firstname, self.lastname, self.address, self.zipcode, self.city_id, self.email, self.phone, self.password, self.role, self.id))
|
||||
""", (Encryption.encrypt(self.username), Encryption.encrypt(self.firstname), Encryption.encrypt(self.lastname), Encryption.encrypt(self.address), Encryption.encrypt(self.zipcode), self.city_id, Encryption.encrypt(self.email), Encryption.encrypt(self.phone), self.password, self.role, self.id))
|
||||
|
||||
self.connection.commit()
|
||||
cur.close()
|
||||
@@ -82,15 +83,15 @@ class User:
|
||||
|
||||
def _set_row_values(self, row):
|
||||
self.id = row[0]
|
||||
self.username = row[1]
|
||||
self.firstname = row[2]
|
||||
self.lastname = row[3]
|
||||
self.address = row[4]
|
||||
self.zipcode = row[5]
|
||||
self.username = Encryption.decrypt(row[1])
|
||||
self.firstname = Encryption.decrypt(row[2])
|
||||
self.lastname = Encryption.decrypt(row[3])
|
||||
self.address = Encryption.decrypt(row[4])
|
||||
self.zipcode = Encryption.decrypt(row[5])
|
||||
self.city_id = row[6]
|
||||
self.email = row[7]
|
||||
self.phone = row[8]
|
||||
self.password = row[9]
|
||||
self.role = row[10]
|
||||
self.email = Encryption.decrypt(row[7])
|
||||
self.phone = Encryption.decrypt(row[8])
|
||||
self.password = Encryption.decrypt(row[9])
|
||||
self.role = Encryption.decrypt(row[10])
|
||||
self.created = row[11]
|
||||
return self
|
Reference in New Issue
Block a user