Login by facebook in angular app with loopback backend

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-03 02:37:09
chilicoder

Here is a valid code.

app.get('/auth/login', function(req, res, next) {
  //workaround for loopback-password 
  //without this angular-loopback would make incorrect authorization header
  res.cookie('access-token', req.signedCookies['access-token']);
  res.cookie('userId', req.user.id);
  res.redirect('/#auth/login');
});

The problem is that loopback-passport signs cookie:

         res.cookie('access-token', info.accessToken.id, { signed: true,
           maxAge: info.accessToken.ttl });

In string it looks something like the following "s:.eBvo8bpo9Q9wnNrPjjlG%2FAcYqWkxEgNFqn%2FO54rdGwY"

But loopback-angular just copies the access-token to header.authorization, so we need to put there plain cookie.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!