forked from React-Group/interstellar_ai
		
	database works like 50%
This commit is contained in:
		
							parent
							
								
									4427774def
								
							
						
					
					
						commit
						36672f42aa
					
				
					 2 changed files with 15 additions and 5 deletions
				
			
		|  | @ -55,9 +55,12 @@ const Login: React.FC = () => { | ||||||
|     const savedAccountName = localStorage.getItem('accountName'); |     const savedAccountName = localStorage.getItem('accountName'); | ||||||
| 
 | 
 | ||||||
|     // Check if savedAccountName or savedAccountEmail is not null before passing to checkCredentials
 |     // 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); |       const success = await checkCredentials(accountIdentifier, password); | ||||||
|       if (success) { |       if (success) { | ||||||
|         setIsLoggedIn(true); // Successful login
 |         setIsLoggedIn(true); // Successful login
 | ||||||
|  |  | ||||||
							
								
								
									
										13
									
								
								py/db.py
									
										
									
									
									
								
							
							
						
						
									
										13
									
								
								py/db.py
									
										
									
									
									
								
							|  | @ -9,9 +9,13 @@ class DB: | ||||||
|         self.database = {} |         self.database = {} | ||||||
| 
 | 
 | ||||||
|     def ensure_username(self, data): |     def ensure_username(self, data): | ||||||
|         if hasattr(data, 'username'): |         print(data) | ||||||
|  |         print(self.database) | ||||||
|  |         if 'username' in data: | ||||||
|  |             print("usr") | ||||||
|             return data.get('username') |             return data.get('username') | ||||||
|         elif hasattr(data, 'email'): |         elif 'email' in data: | ||||||
|  |             print("email") | ||||||
|             for index, entry in self.database: |             for index, entry in self.database: | ||||||
|                 if entry.get('email') == data.get('email'): |                 if entry.get('email') == data.get('email'): | ||||||
|                     return index |                     return index | ||||||
|  | @ -71,10 +75,13 @@ class DB: | ||||||
|         username = self.ensure_username(data) |         username = self.ensure_username(data) | ||||||
|         password = data.get('password') |         password = data.get('password') | ||||||
|         if username not in self.database: |         if username not in self.database: | ||||||
|  |             print("no username") | ||||||
|  |             print(username) | ||||||
|             return False |             return False | ||||||
| 
 | 
 | ||||||
|         stored_hashed_password = self.database[username]["hashed_password"] |         stored_hashed_password = self.database[username]["hashed_password"] | ||||||
|         entered_hashed_password = self.hash_password(password) |         entered_hashed_password = self.hash_password(password) | ||||||
|  |         print(stored_hashed_password == entered_hashed_password) | ||||||
|         return stored_hashed_password == entered_hashed_password |         return stored_hashed_password == entered_hashed_password | ||||||
| 
 | 
 | ||||||
|     def get_data(self, data): |     def get_data(self, data): | ||||||
|  | @ -82,7 +89,7 @@ class DB: | ||||||
|         if not self.check_credentials(data): |         if not self.check_credentials(data): | ||||||
|             return None |             return None | ||||||
| 
 | 
 | ||||||
|         send_back = self.database(username).get('data') |         send_back = self.database[username].get('data') | ||||||
|         return send_back |         return send_back | ||||||
| 
 | 
 | ||||||
|     def save_database(self): |     def save_database(self): | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Patrick_Pluto
						Patrick_Pluto