Код: Выделить всё
@app_reg.post("/confirm")
async def confirm(data: CodeConfirm,
authorization: str = Header(...),
) -> JSONResponse:
"""
Processing of the form for entering the registration confirmation code.
Args:
authorization: Caption Authorization
code: Code from the form.
Returns:
JSONResponse: Code Validation Result.
- 200: Successful validation, returns a success message.
- 422: Validation error, returns an error message.
- 400: Validation error, returns an appropriate message.
Notes:
- Receives data from session, sends to backend, on successful
response from the backend, clears the session.
"""
try:
user_data = get_redis_via_token(authorization, SECRET_KEY_REGISTRATION)
if isinstance(user_data, JSONResponse):
return user_data
email = user_data.get('email')
login = user_data.get('login')
password = user_data.get('password')
verification_code = user_data.get('code')
except Exception as e:
return JSONResponse(content={"message": str(e)}, status_code=400)
result = await Registration.confirm_register(
email, login, password, data.code, verification_code)
if result['status_code'] == 200:
redis_client.delete(f"login:{login}")
return JSONResponse(content={"message": result["message"]},
status_code=200)
else:
return JSONResponse(content={"message": result["message"]},
status_code=400)
Код: Выделить всё
{
"detail": [
{
"type": "missing",
"loc": [
"header",
"authorization"
],
"msg": "Field required",
"input": null
}
]
}
Подробнее здесь: https://stackoverflow.com/questions/790 ... on-problem