diff --git a/package.json b/package.json index 2f32273..72fb90a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wms-core", - "version": "0.10.18", + "version": "0.10.19", "description": "Node web framework", "repository": "git@gitlab.com:ArisuOngaku/wms-core.git", "author": "Alice Gaudon ", diff --git a/src/components/SessionComponent.ts b/src/components/SessionComponent.ts index 696be18..709cadb 100644 --- a/src/components/SessionComponent.ts +++ b/src/components/SessionComponent.ts @@ -36,17 +36,22 @@ export default class SessionComponent extends ApplicationComponent { res.locals.session = req.session; - let _flash: any = null; - res.locals.flash = () => { - if (!_flash) { - _flash = { + let _flash: any = {}; + res.locals.flash = (key?: string) => { + if (key !== undefined) { + if (_flash[key] === undefined) _flash[key] = req.flash(key) || null; + return _flash[key]; + } + + if (_flash._messages === undefined) { + _flash._messages = { info: req.flash('info'), success: req.flash('success'), warning: req.flash('warning'), error: req.flash('error'), }; } - return _flash; + return _flash._messages; }; next(); });