Merge pull request 'main' (#29) from React-Group/interstellar_ai:main into main
Reviewed-on: https://interstellardevelopment.org/code/code/sageTheDm/interstellar_ai/pulls/29
This commit is contained in:
commit
2f84559ec2
2 changed files with 15 additions and 5 deletions
|
@ -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
|
||||
|
|
13
py/db.py
13
py/db.py
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue