Skip to content
This repository has been archived by the owner on Jan 29, 2022. It is now read-only.

Commit

Permalink
[#622] Fix flash notifications not being discarded
Browse files Browse the repository at this point in the history
There was an issue with the `yar` plugin being registered by Glue before the
extension function, thus leading to weird interferences with the session store.

Moved it to `lib/plugins/yar` and registered in `server.js` right after the
extensions.

Fixes #622
  • Loading branch information
nightsh committed Jan 11, 2017
1 parent 7ba4e54 commit 65cd506
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 15 deletions.
2 changes: 2 additions & 0 deletions assets/styles/ot-scss/_flash-messages.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.flash-message {
list-style: none;
padding: 0;
position: fixed;
top: 0;
width: 100%;
Expand Down
15 changes: 0 additions & 15 deletions config/glue.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,6 @@ const manifest = {
select: ['web', 'web-fda'],
},
},
{
plugin: {
register: 'yar',
options: {
storeBlank: false,
cookieOptions: {
password: process.env.SESSION_PASSWORD,
isSecure: false, // FIXME: Set to true in production when issue #100 is fixed
},
},
},
options: {
select: ['web', 'web-fda'],
},
},
],
};

Expand Down
1 change: 1 addition & 0 deletions lib/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const plugins = {
httpErrorHandler: require('./plugins/http-error-handler'),
sendErrorsToSentry: require('./plugins/send-errors-to-sentry'),
sendEmail: require('./plugins/send-email'),
yar: require('./plugins/yar'),
};

module.exports = plugins;
14 changes: 14 additions & 0 deletions lib/plugins/yar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';

const register = {
register: require('yar'),
options: {
storeBlank: false,
cookieOptions: {
password: process.env.SESSION_PASSWORD,
isSecure: false, // FIXME: Set to true in production when issue #100 is fixed
},
},
};

module.exports = register;
4 changes: 4 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ function startOrInitializeServer(resolve, reject) {
server.ext('onPreResponse', plugins.addCurrentURLToContext);
server.ext('onPreResponse', plugins.httpErrorHandler);

// `yar` registration needs to happen after registering `addFlashMessagesToContext`
// and Glue does not allow anything related to `server.ext`
server.register(plugins.yar);

server.views(config.hapi.views);

return server.initialize()
Expand Down

0 comments on commit 65cd506

Please sign in to comment.