From 4892c1c1098bf71df0adf8331ae842c1985a6fe9 Mon Sep 17 00:00:00 2001 From: Kieren Eaton <499977+circulon@users.noreply.github.com> Date: Thu, 22 Aug 2024 11:57:32 +0800 Subject: [PATCH] Fixed errors key missing from session MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added the errors key back into the session flash. Changed the View errors helper name from ‘bag’ back to ‘errors’ --- src/masonite/middleware/route/SessionMiddleware.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/masonite/middleware/route/SessionMiddleware.py b/src/masonite/middleware/route/SessionMiddleware.py index 8d9a0b415..5a1103bf7 100644 --- a/src/masonite/middleware/route/SessionMiddleware.py +++ b/src/masonite/middleware/route/SessionMiddleware.py @@ -17,7 +17,11 @@ def before(self, request, response): request.app.make("request").session = Session # TODO: Remove in Masonite 5 - request.app.make("view").share({"bag": MessageBag(Session.get("errors") or {}).helper}) + 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, _):