inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

자린이님의 게시글

자린이 자린이

@twysg4479

수강평 작성수
-
평균평점
-

게시글 5

질문&답변

"TypeError: Cannot read property 'findOne' of undefined"가 발생합니다.

const LocalStrategy = require('passport-local').Strategy; const { User } = require('../model/user'); module.exports = (passport) => { passport.use( new LocalStrategy( { usernameField: 'email', passwordField: 'password' }, async (email, password, done) => { // done(에러, 성공, 실패) try { console.log('어디가 에러나는거야'); const exUser = await User.findOne({ email: email }); if (exUser) { // 비밀번호 검사 const result = await bcrypt.compare(password, exUser.password); if (result) { done(null, exUser); } else { done(null, false, { message: '비밀번호가 일치하지 않습니다.' }); } } else { done(null, false, { message: '가입되지 않은 회원입니다.' }); } } catch (err) { console.error(err); done(err); } } ) ); }; localstrategy.js 코드입니다. 네, authenticate 안에서는 findOne을 해주지 않았습니다.

좋아요수
0
댓글수
7
조회수
1077