marklogic-community / slush-marklogic-node

Slush generator for a MarkLogic/node project

Home Page:https://github.com/marklogic-community/slush-marklogic-node/wiki

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Every reload of the '/search' requires the user to log-in again

sashamitrovich opened this issue · comments

This happens with MarkLogic 9.0-3.1

commented

That has been bothering me a lot since 9.0-3 too! I have been digging in, and I think I found the culprit. It goes wrong at the initial call to /api/user/status after a browser reload. At that point the middle-tier is initialized, and authenticator is prepared. Unfortunately, the route for /api/user/status passes in the wrong path to calculate the auth header, so it gets rejected by ML since 9.0-3.

This and following line:

https://github.com/marklogic-community/slush-marklogic-node/blob/master/app/templates/node-server/routes.js#L49

needs to be replaced with:

var passportUser = req.session.passport.user;
var path = '/v1/documents?uri=/api/users/' + passportUser.username + '.json';

After that it all runs as before!

Verified, the fix works on ML 9.0-3.1!
(This really helps preventing insanity from constant logging in, thanks!)