From 0a95becf1ad4428ec845af7c51c8ff53e8204218 Mon Sep 17 00:00:00 2001 From: fedecarboni7 Date: Mon, 12 Aug 2024 23:56:53 -0300 Subject: [PATCH] =?UTF-8?q?chore:=20primero=20verifico=20que=20el=20usuari?= =?UTF-8?q?o=20no=20est=C3=A9=20registrado=20y=20despues=20la=20contrase?= =?UTF-8?q?=C3=B1a?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/main.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/main.py b/app/main.py index bdaa25f..02537ea 100644 --- a/app/main.py +++ b/app/main.py @@ -132,17 +132,16 @@ async def signup( # Validar nombre de usuario y contraseña try: validate_username(username) + + user = execute_with_retries(query_user, db, username) + if user: + raise ValueError("Usuario ya registrado") + validate_password(password) except ValueError as e: return templates.TemplateResponse("signup.html", {"request": request, "error": str(e)}) - - try: - user = execute_with_retries(query_user, db, username) except OperationalError: return HTMLResponse("Error al acceder a la base de datos. Inténtalo de nuevo más tarde.", status_code=500) - - if user: - return templates.TemplateResponse(request=request, name="signup.html", context={"error": "Usuario ya registrado"}) new_user = User(username=username) new_user.set_password(password)