Login by facebook in angular app with loopback backend

后端 未结 1 1926
盖世英雄少女心
盖世英雄少女心 2021-02-05 22:24

I\'m making an angular application with strongloop loopback backend.

Also I integrating a third party login by facebook using loopback-passport module.

everythin

1条回答
  •  抹茶落季
    2021-02-05 22:57

    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.

    0 讨论(0)
提交回复
热议问题