Implement user addition in UserService online_chat.py

pull/824/head
vivekmaru36 2023-12-31 22:17:06 +05:30 committed by GitHub
parent a07e261677
commit 1d76b529de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -8,7 +8,13 @@ class UserService(object):
self.users_by_id = {} # key: user id, value: User self.users_by_id = {} # key: user id, value: User
def add_user(self, user_id, name, pass_hash): def add_user(self, user_id, name, pass_hash):
pass if user_id not in self.users_by_id:
new_user = User(user_id, name, pass_hash)
self.users_by_id[user_id] = new_user
return new_user
else:
# User with this ID already exists
return None
def remove_user(self, user_id): def remove_user(self, user_id):
pass pass