Spaces:
Running
Running
github-actions[bot] commited on
Commit ·
08797bf
1
Parent(s): 0fa212a
deploy: backend from f370a16
Browse files5211 unmodified lines52125213521452155216521752185219522052211823 unmodified lines7045704670477048704970507051705241 unmodified lines7094709570967097709870995211 unmodified linesdef _generate_temporary_password(length: int = 12) -> str:alphabet = string.ascii_letters + string.digitswhile True:candidate = "".join(secrets.choice(alphabet) for _ in range(max(10, length)))if any(ch.islower() for ch in candidate) and any(ch.isupper() for ch in candidate) and any(ch.isdigit() for ch in candidate):return candidate1823 unmodified linesraise HTTPException(status_code=400, detail="A valid email address is required")temporary_password = (payload.temporary_password or "").strip()if len(temporary_password) < 8:raise HTTPException(status_code=400, detail="Temporary password must be at least 8 characters")grade = (payload.grade or "").strip()section = (payload.section or "").strip()41 unmodified linesstatus_code=409,detail="An account with this email already exists.",)logger.error("Auth user creation failed for %s: %s", email, create_auth_error)raise HTTPException(status_code=500, detail="Failed to create authentication account.")5211 unmodified lines52125213521452155216521752185219522052215222522352245225522652271823 unmodified lines7051705270537054705570567057705870597060706170627063706470657066706741 unmodified lines710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371345211 unmodified linesdef _generate_temporary_password(length: int = 12) -> str:special_characters = "!@#$%&*"alphabet = string.ascii_letters + string.digits + special_characterswhile True:candidate = "".join(secrets.choice(alphabet) for _ in range(max(12, length)))if (any(ch.islower() for ch in candidate)and any(ch.isupper() for ch in candidate)and any(ch.isdigit() for ch in candidate)and any(ch in special_characters for ch in candidate)):return candidate1823 unmodified linesraise HTTPException(status_code=400, detail="A valid email address is required")temporary_password = (payload.temporary_password or "").strip()if (len(temporary_password) < 8or not re.search(r"[A-Z]", temporary_password)or not re.search(r"[a-z]", temporary_password)or not re.search(r"\d", temporary_password)or not re.search(r"[^A-Za-z0-9]", temporary_password)):raise HTTPException(status_code=400,detail="Temporary password must be at least 8 characters and include uppercase, lowercase, a number, and a special character.",)grade = (payload.grade or "").strip()section = (payload.section or "").strip()41 unmodified linesstatus_code=409,detail="An account with this email already exists.",)if ("password_does_not_meet_requirements" in error_textor "password requirements" in error_textor "weak password" in error_textor "password must" in error_text):raise HTTPException(status_code=400,detail="Password does not meet authentication policy requirements. Ensure it includes uppercase, lowercase, numbers, and special characters.",)if ("invalid_email" in error_textor "invalid email" in error_textor "improperly formatted" in error_textor "malformed email" in error_text):raise HTTPException(status_code=400,detail="The email address is improperly formatted or not accepted.",)logger.error("Auth user creation failed for %s: %s", email, create_auth_error)raise HTTPException(status_code=500, detail="Failed to create authentication account.")
main.py+40-5