From 47038681c47e5eb7f3fd13416ba2b8fc9e6bbedf Mon Sep 17 00:00:00 2001 From: Kieren Eaton <499977+circulon@users.noreply.github.com> Date: Thu, 22 Aug 2024 18:52:32 +0800 Subject: [PATCH] upadted session re-add for uniformity accross modules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Other modules will probably not expect a MessageBag as the content of the session ‘errors’ key. So just pass it through --- src/masonite/middleware/route/SessionMiddleware.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/masonite/middleware/route/SessionMiddleware.py b/src/masonite/middleware/route/SessionMiddleware.py index bf0f4e2b..5e0a02af 100644 --- a/src/masonite/middleware/route/SessionMiddleware.py +++ b/src/masonite/middleware/route/SessionMiddleware.py @@ -16,13 +16,15 @@ 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 - errors = Session.get("errors") or {} - request.app.make("view").share({"errors": MessageBag(errors).helper}) - # errors are stored in session flash so 'getting' them actually clears them - # if any then re-add them to the session + # TODO: Check this in Masonite 5 + # errors are stored in session flash so 'getting' them + # actually clears them out of the session + errors = Session.get("errors") + request.app.make("view").share({"errors": MessageBag(errors or {}).helper}) + # if any errors then re-add them to the session if errors: - Session.flash('errors', errors) + Session.flash("errors", errors) + return request def after(self, request, _):