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: flash messages were not displayed on Redirect #3420

Merged
merged 18 commits into from
Apr 28, 2024

Conversation

euri10
Copy link
Contributor

@euri10 euri10 commented Apr 23, 2024

@euri10 euri10 requested review from a team as code owners April 23, 2024 07:59
@github-actions github-actions bot added area/plugins This PR involves changes to the plugins size: small type/bug pr/external Triage Required 🏥 This requires triage labels Apr 23, 2024
@euri10 euri10 changed the title fix: Redirect on flash messages were not displayed fix: flash messages were not displayed on Redirect Apr 23, 2024
Copy link

codecov bot commented Apr 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.29%. Comparing base (0ee3125) to head (f287fb5).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3420   +/-   ##
=======================================
  Coverage   98.29%   98.29%           
=======================================
  Files         328      328           
  Lines       14857    14864    +7     
  Branches     2356     2358    +2     
=======================================
+ Hits        14603    14610    +7     
  Misses        116      116           
  Partials      138      138           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

litestar/plugins/flash.py Outdated Show resolved Hide resolved
Copy link
Contributor

@peterschutt peterschutt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the flash config's reference to the session config necessary? I.e., can we check for a session middleware instead?

Also, I understand that current behavior is broken WRT to redirects, but should we try to make this change in a more backward compatible manner? I.e., if a session middleware is not found, fall back to the current implementation and include a deprecation warning that a session middleware will be required in a future version.

litestar/plugins/flash.py Outdated Show resolved Hide resolved
litestar/plugins/flash.py Outdated Show resolved Hide resolved
@peterschutt peterschutt enabled auto-merge (squash) April 28, 2024 21:30
@peterschutt peterschutt merged commit c625ce7 into main Apr 28, 2024
26 checks passed
@peterschutt peterschutt deleted the 3325_use_session_flash branch April 28, 2024 21:33
Copy link

sonarcloud bot commented Apr 28, 2024

Copy link

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

peterschutt pushed a commit that referenced this pull request May 1, 2024
* fix: Redirect on flash messages were not displayed

* Update litestar/plugins/flash.py

Co-authored-by: Peter Schutt <peter.github@proton.me>

* nit

* checking for SessionMiddleware breaks tests ?

* using context vars passes the tests which reveals tests are incorrect...

* Revert "using context vars passes the tests which reveals tests are incorrect..."

This reverts commit fd55270.

* Revert "checking for SessionMiddleware breaks tests ?"

This reverts commit bbf6236.

* check config differently in app_init

* Removed the session_config from the plugin config

* Fix mypy weirdness: see explanation in https://mypy.readthedocs.io/en/stable/type_narrowing.html#issubclass

* cant fix mypy

* fix: use `is_class_and_subclass()` for mw check.

* Added test for better coverage on middleware type switch

* Add check for `session_auth.middleware.MiddlewareWrapper`

Improve search for session middleware by also looking for `MiddlewareWrapper`. It adds `SessionMiddleware` within itself if it is present.

---------

Co-authored-by: Peter Schutt <peter.github@proton.me>
(cherry picked from commit c625ce7)
peterschutt pushed a commit that referenced this pull request May 2, 2024
* fix: Redirect on flash messages were not displayed

* Update litestar/plugins/flash.py

Co-authored-by: Peter Schutt <peter.github@proton.me>

* nit

* checking for SessionMiddleware breaks tests ?

* using context vars passes the tests which reveals tests are incorrect...

* Revert "using context vars passes the tests which reveals tests are incorrect..."

This reverts commit fd55270.

* Revert "checking for SessionMiddleware breaks tests ?"

This reverts commit bbf6236.

* check config differently in app_init

* Removed the session_config from the plugin config

* Fix mypy weirdness: see explanation in https://mypy.readthedocs.io/en/stable/type_narrowing.html#issubclass

* cant fix mypy

* fix: use `is_class_and_subclass()` for mw check.

* Added test for better coverage on middleware type switch

* Add check for `session_auth.middleware.MiddlewareWrapper`

Improve search for session middleware by also looking for `MiddlewareWrapper`. It adds `SessionMiddleware` within itself if it is present.

---------

Co-authored-by: Peter Schutt <peter.github@proton.me>
(cherry picked from commit c625ce7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: Plugin "Flash Messages" not working with "Redirect" Response
3 participants