app.post('/logink',function(요청,응답){
// console.log(요청.body);
// db.collection('login').findOne({id : 요청.body.id},function(에러,결과){
// console.log(결과);
// if(결과 == null){
// db.collection('login').insertOne({id : 요청.body.id , ps : 요청.body.ps , nikname : 요청.body.nikName},function(에러,결과){
// 응답.redirect('/');
// });
// }else{
// 응답.send('이미존재합니다');
// }
// });
// });
이렇게 하면 id중복체크 되서 이미있는거 쓰면 안된다고 잘 되긴하는데 .... 문제는 요청.body.nikName 요것이 중복체크가 안되요 ㅠㅠ
그래가지고 ㅠㅠ 반대로 findOne({nikname : 요청.body.nikName} 요렇게 해보믄 닉네임은 또 중복으로 안되서 좋은데 아이디가 중복이
됩니다 ㅠㅠ ... 그래서 그냥
app.post('/logink',function(요청,응답){
db.collection('login').find().toArray(function(에러,결과){
if(결과 == null){
db.collection('login').insertOne({id : 요청.body.id , ps : 요청.body.ps , nikname : 요청.body.nikName},function(에러,결과){
응답.redirect('/');
});
}else{
응답.send('이미존재합니다');
}
})
})
요렇게 findOne이아니고 그냥 다 찾아 버려서 하면 아이디 닉네임 다 중복체크 되는데 문제는 그러면 비번도 될꺼라는거에요 ㅠ
비번은 중복되도 상관 없자나요 .. 그래서......
// app.post('/logink',function(요청,응답){
// db.collection('login').findOne({id : 요청.body.id},function(에러,결과){
// if(결과 == null){
// db.collection('login').findOne({nikname : 요청.body.nikName},function(에러,result){
// if(result == null){
// db.collection('login').insertOne({id : 요청.body.id , ps : 요청.body.ps , nikname : 요청.body.nikName},function(에러,결과){
// 응답.redirect('/');
// });
// }else{
// 응답.send('이미존재합니다');
// }
// })
// }
// })
// })
요렇게 하면 되지 않을까 했는데 ... 안되네요 ㅠㅠ 왜 안될까요 ㅠㅠ 에러는 안나는데 응답이 없어서 돌아가는 그거있자나요.
그리고 하나더 그 로그인 하면 로그아웃 할려면 어떤거를 지워야되나요 제이쿼리에서 배운 로컬스트레이지 그거 삭제하는법
그렇게 버튼 만들어서 로그아웃 하면되나요?