diff --git a/app/components/Login.tsx b/app/components/Login.tsx index 1d8a4e6..c766f09 100644 --- a/app/components/Login.tsx +++ b/app/components/Login.tsx @@ -55,12 +55,9 @@ const Login: React.FC = () => { const savedAccountName = localStorage.getItem('accountName'); // Check if savedAccountName or savedAccountEmail is not null before passing to checkCredentials - var accountIdentifier = savedAccountName || savedAccountEmail; - if (!accountIdentifier) { - accountIdentifier = accountName - } + const accountIdentifier = savedAccountName || savedAccountEmail; - if (accountIdentifier && password) { + if (accountIdentifier && password === savedAccountPassword) { const success = await checkCredentials(accountIdentifier, password); if (success) { setIsLoggedIn(true); // Successful login diff --git a/py/db.py b/py/db.py index 778c6c7..a20cd84 100644 --- a/py/db.py +++ b/py/db.py @@ -9,13 +9,9 @@ class DB: self.database = {} def ensure_username(self, data): - print(data) - print(self.database) - if 'username' in data: - print("usr") + if hasattr(data, 'username'): return data.get('username') - elif 'email' in data: - print("email") + elif hasattr(data, 'email'): for index, entry in self.database: if entry.get('email') == data.get('email'): return index @@ -75,13 +71,10 @@ 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): @@ -89,7 +82,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):