Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use ASGIConnection instead of Request for flash #3626

Merged
merged 1 commit into from
Jul 15, 2024
Merged

Conversation

cofin
Copy link
Member

@cofin cofin commented Jul 13, 2024

Description

Currently, the FlashPlugin expects the request parameter to be a type of Request. However, there's no reason it can't use the parent class ASGIConnection.

Doing this, allows for flash to be called in guards that expect an ASGIConnection instead of Request:

def requires_active_user(connection: ASGIConnection, _: BaseRouteHandler) -> None:
    if connection.user.is_active:
        return
    msg = "Your user account is inactive."
    flash(connection, msg, category="error")
    raise PermissionDeniedException(msg)

Closes

@cofin cofin requested review from a team as code owners July 13, 2024 21:55
@github-actions github-actions bot added area/plugins This PR involves changes to the plugins size: small type/bug pr/internal labels Jul 13, 2024
Copy link

Copy link

Documentation preview will be available shortly at https://litestar-org.github.io/litestar-docs-preview/3626

@cofin cofin merged commit b82225a into main Jul 15, 2024
27 checks passed
@cofin cofin deleted the flash-connection branch July 15, 2024 14:51
Alc-Alc pushed a commit that referenced this pull request Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/plugins This PR involves changes to the plugins pr/internal size: small type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants