def add_user(cls, username, password): for userid in cls.user_dict: if cls.user_dict[userid]['username'] == username: return "User already exists" hashed_pass = PasswordManager.hash(password) id = str(len(cls.user_dict) + 1) cls.user_dict[id] = User(id, username, hashed_pass) return None
def modify_user(cls, username, password): for userid in cls.user_dict: if cls.user_dict[userid]['username'] == username: hashed_pass = PasswordManager.hash(password) cls.user_dict[id].set_password(hashed_pass)
def set_password(self, password): self._password = PasswordManager.hash(password)
def authenticate(self, password): if self._password == PasswordManager.hash(password): self._authenticated = True return self._authenticated