forked from React-Group/interstellar_ai
		
	More Database Functions #14
					 2 changed files with 14 additions and 6 deletions
				
			
		|  | @ -49,7 +49,9 @@ class API: | ||||||
|             if action == "change_password": |             if action == "change_password": | ||||||
|                 self.db.update_password(data) |                 self.db.update_password(data) | ||||||
|             if action == "get_data": |             if action == "get_data": | ||||||
|                 self.db.get_additional_info(data) |                 self.db.get_data(data) | ||||||
|  |             if action == "change_data": | ||||||
|  |                 self.db.change_data(data) | ||||||
|             if action == "check_credentials": |             if action == "check_credentials": | ||||||
|                 self.db.check_credentials(data) |                 self.db.check_credentials(data) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										16
									
								
								py/db.py
									
										
									
									
									
								
							
							
						
						
									
										16
									
								
								py/db.py
									
										
									
									
									
								
							|  | @ -19,9 +19,17 @@ class DB: | ||||||
|         user_data = {"hashed_password": hashed_password} |         user_data = {"hashed_password": hashed_password} | ||||||
|         self.database[username] = user_data |         self.database[username] = user_data | ||||||
| 
 | 
 | ||||||
|  |     def change_data(self, data): | ||||||
|  |         username = data.get['username'] | ||||||
|  |         data = data.get['data'] | ||||||
|  |         if not self.check_credentials(data): | ||||||
|  |             return False | ||||||
|  | 
 | ||||||
|  |         self.database[username]['data'] = data | ||||||
|  |         return True | ||||||
|  | 
 | ||||||
|     def update_password(self, data): |     def update_password(self, data): | ||||||
|         username = data.get['username'] |         username = data.get['username'] | ||||||
|         old_password = data.get['old_password'] |  | ||||||
|         new_password = data.get['new_password'] |         new_password = data.get['new_password'] | ||||||
|         if not self.check_credentials(data): |         if not self.check_credentials(data): | ||||||
|             return False |             return False | ||||||
|  | @ -40,12 +48,10 @@ class DB: | ||||||
|         entered_hashed_password = self.hash_password(password) |         entered_hashed_password = self.hash_password(password) | ||||||
|         return stored_hashed_password == entered_hashed_password |         return stored_hashed_password == entered_hashed_password | ||||||
| 
 | 
 | ||||||
|     def get_additional_info(self, data): |     def get_data(self, data): | ||||||
|         username = data.get['username'] |         username = data.get['username'] | ||||||
|         password = data.get['password'] |  | ||||||
|         if not self.check_credentials(data): |         if not self.check_credentials(data): | ||||||
|             return None |             return None | ||||||
| 
 | 
 | ||||||
|         send_back = self.database[username] |         send_back = self.database[username].get['data'] | ||||||
|         del send_back['hashed_password'] |  | ||||||
|         return send_back |         return send_back | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue