Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting access token cookie in Loopback?

I want to use cookies to keep a user logged in.

On this page here they say

To use cookies for authentication, add the following to server.js (before boot):

app.use(loopback.token({ model: app.models.accessToken }));

Seemed simple enough. I figured the cookies were set by Loopback automatically during the login process but it's still not working, I check my cookies in Chrome dev tools and none are set.

Am I missing something? Otherwise, what's the best way to hook into the login method to have set the cookie/header?

I found docs on the loopback.token() method here, which says exactly where it checks for the token.

like image 265
Kenmore Avatar asked Mar 13 '16 10:03

Kenmore


1 Answers

I got it to work. The cookie wasn't being signed.

I'm pretty much new to Express and lower-level stuff like this. I remembered reading that the cookie had to be signed but it slipped my mind that I had to pass "signed: true".

My issue on Github if that helps anyone else.

like image 76
Kenmore Avatar answered Nov 15 '22 04:11

Kenmore