This commit is contained in:
parent 06a5a758a3
commit 58fa7d1ee6
19 changed files with 567 additions and 377 deletions

View file

@ -23,7 +23,8 @@ class JsonStorage:
try:
logger.info(f"Проверка существования файла {self.file_path}")
if not os.path.exists(self.file_path):
logger.info(f"Создание директории {os.path.dirname(self.file_path)}")
logger.info(
f"Создание директории {os.path.dirname(self.file_path)}")
os.makedirs(os.path.dirname(self.file_path), exist_ok=True)
logger.info(f"Создание файла {self.file_path}")
with open(self.file_path, "w") as f:
@ -84,7 +85,8 @@ class JsonStorage:
users.append(new_user)
data["next_id"] = next_id + 1
self._write_data(data)
logger.info(f"Пользователь {user.username} успешно зарегистрирован")
logger.info(
f"Пользователь {user.username} успешно зарегистрирован")
return UserResponse(
id=new_user["id"],
username=new_user["username"],
@ -115,6 +117,7 @@ class JsonStorage:
)
raise
def verify_password(self, plain_password: str, hashed_password: str) -> bool:
def verify_password(self, plain_password: str,
hashed_password: str) -> bool:
"""Проверяет пароль"""
return self.pwd_context.verify(plain_password, hashed_password)