Skip to content

Instantly share code, notes, and snippets.

@sirgallifrey
Created January 31, 2017 20:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sirgallifrey/7c4909866262503ac7a1da509a03623e to your computer and use it in GitHub Desktop.
Save sirgallifrey/7c4909866262503ac7a1da509a03623e to your computer and use it in GitHub Desktop.
always feed user info into Vision's .view context
server.ext('onPreResponse', (request, reply) => {
const response = request.response;
if (response.variety && response.variety === 'view') {
response.source.context = response.source.context || {};
if (request.auth.isAuthenticated) {
response.source.context.user = {
name: request.auth.credentials.name
};
}
}
return reply.continue();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment