database works like 50%

This commit is contained in:
Patrick_Pluto 2024-09-30 16:13:04 +02:00
parent 4427774def
commit 36672f42aa
2 changed files with 15 additions and 5 deletions

View file

@ -55,9 +55,12 @@ const Login: React.FC = () => {
const savedAccountName = localStorage.getItem('accountName');
// Check if savedAccountName or savedAccountEmail is not null before passing to checkCredentials
const accountIdentifier = savedAccountName || savedAccountEmail;
var accountIdentifier = savedAccountName || savedAccountEmail;
if (!accountIdentifier) {
accountIdentifier = accountName
}
if (accountIdentifier && password === savedAccountPassword) {
if (accountIdentifier && password) {
const success = await checkCredentials(accountIdentifier, password);
if (success) {
setIsLoggedIn(true); // Successful login

View file

@ -9,9 +9,13 @@ class DB:
self.database = {}
def ensure_username(self, data):
if hasattr(data, 'username'):
print(data)
print(self.database)
if 'username' in data:
print("usr")
return data.get('username')
elif hasattr(data, 'email'):
elif 'email' in data:
print("email")
for index, entry in self.database:
if entry.get('email') == data.get('email'):
return index
@ -71,10 +75,13 @@ class DB:
username = self.ensure_username(data)
password = data.get('password')
if username not in self.database:
print("no username")
print(username)
return False
stored_hashed_password = self.database[username]["hashed_password"]
entered_hashed_password = self.hash_password(password)
print(stored_hashed_password == entered_hashed_password)
return stored_hashed_password == entered_hashed_password
def get_data(self, data):
@ -82,7 +89,7 @@ class DB:
if not self.check_credentials(data):
return None
send_back = self.database(username).get('data')
send_back = self.database[username].get('data')
return send_back
def save_database(self):