def get_user(user_id=None, username=None): global _users_data if not _users_data: _users_data = {} with open(os.path.join(const.DATA_DIR, "users.csv")) as f: user_dict = util.csv_to_array_of_dicts(f) for user in user_dict: new_user = UserMixin() new_user.id = user["id"] new_user.username = user["name"] new_user.password = user["password"] _users_data[new_user.get_id()] = new_user if user_id is None: for user in _users_data.values(): if user.username == username: return user if user_id in _users_data: return _users_data[user_id] else: return False
def get_id(self): """Returns the user identification attribute. This will be `fs_uniquifier` if that is available, else base class id (which is via Flask-Login and is user.id). .. versionadded:: 3.4.0 """ if hasattr(self, "fs_uniquifier") and self.fs_uniquifier is not None: # Use fs_uniquifier as alternative_id if available and not None alternative_id = str(self.fs_uniquifier) if len(alternative_id) > 0: # Return only if alternative_id is a valid value return alternative_id # Use upstream value if alternative_id is unavailable return BaseUserMixin.get_id(self)
def get_id(self): return UserMixin.get_id(self)