Created
January 31, 2017 20:02
-
-
Save sirgallifrey/7c4909866262503ac7a1da509a03623e to your computer and use it in GitHub Desktop.
always feed user info into Vision's .view context
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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