Skip to content

Commit

Permalink
Remove captcha from edit endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
Darky2020 committed Sep 15, 2024
1 parent f1042db commit 5762855
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 22 deletions.
21 changes: 2 additions & 19 deletions app/edit/dependencies.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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),
Expand Down
3 changes: 0 additions & 3 deletions app/edit/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
validate_edit_close,
validate_content,
validate_edit_id,
check_captcha,
)

from .schemas import (
Expand Down Expand Up @@ -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
Expand All @@ -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)

Expand Down

0 comments on commit 5762855

Please sign in to comment.