Add frontend support for custom flashed data keys
This commit is contained in:
parent
ca39c3e538
commit
e72bb08a66
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "wms-core",
|
"name": "wms-core",
|
||||||
"version": "0.10.18",
|
"version": "0.10.19",
|
||||||
"description": "Node web framework",
|
"description": "Node web framework",
|
||||||
"repository": "git@gitlab.com:ArisuOngaku/wms-core.git",
|
"repository": "git@gitlab.com:ArisuOngaku/wms-core.git",
|
||||||
"author": "Alice Gaudon <alice@gaudon.pro>",
|
"author": "Alice Gaudon <alice@gaudon.pro>",
|
||||||
|
@ -36,17 +36,22 @@ export default class SessionComponent extends ApplicationComponent<void> {
|
|||||||
|
|
||||||
res.locals.session = req.session;
|
res.locals.session = req.session;
|
||||||
|
|
||||||
let _flash: any = null;
|
let _flash: any = {};
|
||||||
res.locals.flash = () => {
|
res.locals.flash = (key?: string) => {
|
||||||
if (!_flash) {
|
if (key !== undefined) {
|
||||||
_flash = {
|
if (_flash[key] === undefined) _flash[key] = req.flash(key) || null;
|
||||||
|
return _flash[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_flash._messages === undefined) {
|
||||||
|
_flash._messages = {
|
||||||
info: req.flash('info'),
|
info: req.flash('info'),
|
||||||
success: req.flash('success'),
|
success: req.flash('success'),
|
||||||
warning: req.flash('warning'),
|
warning: req.flash('warning'),
|
||||||
error: req.flash('error'),
|
error: req.flash('error'),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return _flash;
|
return _flash._messages;
|
||||||
};
|
};
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user