Sessions, Cookies and loopback middleware order ?

1,158 views
Skip to first unread message

Pandaiolo

unread,
Apr 24, 2014, 1:13:24 PM4/24/14
to loopb...@googlegroups.com
Hi,

Did anybody already used session cookies with Loopback ?

I am trying to use a specific name both for the cookie and for the header field, but without success


Here is my preprocessing middleware code :

app.use(loopback.favicon());
app.use(loopback.logger(app.get('env') === 'development' ? 'dev' : 'default'));
app.use(loopback.compress());
app.use(loopback.cookieParser(app.get('secretcookie')));
// bodyParser commented and split to comment file upload out
// app.use(loopback.bodyParser());
app.use(loopback.json());
app.use(loopback.urlencoded());
// Comment below to disable file upload
// app.use(loopback.multipart());
app.use(loopback.methodOverride());

app.use(loopback.token({
    model: app.models.accessToken,
    cookies: ['my-auth'],
    headers: ['X-My-Auth'],
}));

No cookies are sent, and the token in the header is still "authorization"

I also tried moving app.enableAuth() before or after this preprocessing code, with no effect

Any help appreciated

Thanks

--
Aurelien

Pandaiolo

unread,
Apr 24, 2014, 1:34:53 PM4/24/14
to loopb...@googlegroups.com
Got it for the authorization header, it's in the request, so client side, and it is defined in angular generated services

I don't find the issue with the cookie

Pandaiolo

unread,
Apr 24, 2014, 2:03:36 PM4/24/14
to loopb...@googlegroups.com
Ok I think I have to do it... I searched for res.cookie in the whole node_modules/loopback with no relevant occurrence

I'll try implementing it at user login in my app
Reply all
Reply to author
Forward
0 new messages