From 57628554ff0a4b6a8f539a1c28f7be97f2ddace1 Mon Sep 17 00:00:00 2001 From: Yaroslaw Biloshytskyi Date: Sun, 15 Sep 2024 13:51:29 +0300 Subject: [PATCH] Remove captcha from edit endpoints --- app/edit/dependencies.py | 21 ++------------------- app/edit/router.py | 3 --- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/app/edit/dependencies.py b/app/edit/dependencies.py index 96b6d3ea..447b371e 100644 --- a/app/edit/dependencies.py +++ b/app/edit/dependencies.py @@ -1,19 +1,13 @@ from sqlalchemy.ext.asyncio import AsyncSession from app.utils import check_user_permissions +from app.dependencies import auth_required from app.database import get_session -from fastapi import Depends, Header -from app.models import AuthToken from app.errors import Abort +from fastapi import Depends from app import constants from . import service from . import utils -from app.dependencies import ( - check_captcha as _check_captcha, - auth_token_optional, - auth_required, -) - from app.service import ( get_user_by_username, get_content_by_slug, @@ -193,17 +187,6 @@ async def validate_edit_create( return args -async def check_captcha( - captcha: str | None = Header(None, alias="captcha"), - auth_token: AuthToken | None = Depends(auth_token_optional), -): - # If authorized through third-party client - disable captcha validation - if auth_token is not None and auth_token.client is not None: - return True - - return await _check_captcha(captcha) - - # Todo: perhaps the log based rate limiting logic could be abstracted in the future? async def validate_edit_create_rate_limit( session: AsyncSession = Depends(get_session), diff --git a/app/edit/router.py b/app/edit/router.py index 2afb813e..e8d0ed8a 100644 --- a/app/edit/router.py +++ b/app/edit/router.py @@ -40,7 +40,6 @@ validate_edit_close, validate_content, validate_edit_id, - check_captcha, ) from .schemas import ( @@ -88,7 +87,6 @@ async def create_edit( ), args: EditArgs = Depends(validate_edit_create), author: User = Depends(validate_edit_create_rate_limit), - _: bool = Depends(check_captcha), ): return await service.create_pending_edit( session, content_type, content, args, author @@ -101,7 +99,6 @@ async def update_edit( args: EditArgs = Depends(validate_edit_update_args), edit: Edit = Depends(validate_edit_update), user: User = Depends(validate_edit_update_rate_limit), - _: bool = Depends(check_captcha), ): return await service.update_pending_edit(session, edit, user, args)