From a020b7ab3939d63108c1c9bc245603ff10033724 Mon Sep 17 00:00:00 2001 From: Gregor Date: Thu, 5 Jan 2017 10:59:25 -0800 Subject: [PATCH] docs(pre-auth-hook): clarify .then nesting with comment https://github.com/hoodiehq/hoodie-server/pull/526#discussion_r94762337 --- lib/config/store/pre-auth-hook.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/config/store/pre-auth-hook.js b/lib/config/store/pre-auth-hook.js index e55d5b1..e196870 100644 --- a/lib/config/store/pre-auth-hook.js +++ b/lib/config/store/pre-auth-hook.js @@ -40,6 +40,10 @@ function onStorePreAuth (request, reply) { return server.plugins.account.api.sessions.find(sessionToken) + // we have to nest the .then callback here because of the `return` + // statements above. If we would chain the .then below outside of this + // `.then`, then it would be executed after the two `return` statements + // above and cause `reply` to be called twice .then(function (session) { delete request.headers.authorization request.headers.cookie = 'AuthSession=' + session.id