Skip to content

Commit

Permalink
fixed session flash errors missing
Browse files Browse the repository at this point in the history
session flash now contains errors key as it did previously.
The errors are now a MessageBag which aligns the Session with the View helper ‘errors()’
  • Loading branch information
circulon committed Aug 22, 2024
1 parent b2a2d27 commit d8075c8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/masonite/middleware/route/SessionMiddleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ def before(self, request, response):
request.app.make("response").with_success = self.with_success
request.app.make("request").session = Session

# TODO: Remove in Masonite 5
bag = MessageBag(Session.get("errors") or {})
request.app.make("view").share({"errors": bag.helper})
# errors are stored in session flash so 'getting' them actually clears them
# so re-add them to the session as a MessageBag
Session.flash('errors', bag)
return request

def after(self, request, _):
Expand Down

0 comments on commit d8075c8

Please sign in to comment.