노드 폴더에서 npm install bcrypt 하여 설치
const hashPass = bcrypt.hashSync(pass, 10);
export async function getLogin(id) {
const sql = `select count(pass) as cnt ,ANY_VALUE(pass) as pass from shoppy_member where id = ? ; ` // 로그인 진행시 count 함수를 사용
return db
.execute(sql, [id])
.then((row) => row[0][0]);
}
export async function getLogin(req, res) {
const { id, pass } = req.body;
const result = await memberRepository.getLogin(id);
if (result.cnt === 1) {
if (await bcrypt.compare(pass, result.pass)) {
result.login_result = true
} else {
result.login_result = false
}
} else {
result.login_result = false
}
console.log(result);
res.json(result)
};