반응형
Passport Version 0.6.0
패키지를 최신 버전으로 업그레이드하면서 기존에 잘 작동했던 passport 코드에서 오류가 발생했다.
^0.5.3 -> ^0.6.0
기존에는 아래와 같이 사용했었다.
userRouter.get('/logout', (req, res) => {
req.logout();
res.clearCookie('token');
res.redirect(req.get('Referrer'));
});
passport 0.6.0버전 업데이트 내용을 보면 기존의 req.logout()은 동기적으로 작동했지만, 0.6.0 이후로는 비동기 함수가 되었다. 따라서 콜백함수를 logout에 넘겨주는 방식으로 써주면 된다.
userRouter.get('/logout', (req, res) => {
req.logout(function () {
res.clearCookie('token');
res.redirect(req.get('Referrer'));
});
});
References
https://www.passportjs.org/tutorials/password/logout/
https://medium.com/passportjs/fixing-session-fixation-b2b68619c51d
https://stackoverflow.com/questions/72336177/error-reqlogout-requires-a-callback-function
반응형
'Trouble Shooting' 카테고리의 다른 글
yarn unknown workspace 오류 해결 (0) | 2023.05.23 |
---|---|
Delete `␍`eslint(prettier/prettier) 해결하기 (0) | 2023.05.18 |
[Next.js] Component selectors can only be used in conjunction with @emotion/babel-plugin 해결 (0) | 2023.02.23 |
[Github Actions] the process '/usr/bin/git' failed with exit code 128 해결 (0) | 2023.02.21 |
[Nginx] 페이지 새로고침 시 Page Not Found 오류 해결 (1) | 2023.02.07 |