Heeyeon

Add additional function

......@@ -64,11 +64,13 @@ passport.use(new LocalStrategy({
console.log(user);
//아이디가 다를때
if (id !== user.email)
return done(null, false, { message: '아이디가 다르다' });
if (id !== user.email){
//alert("존재하는 아이디가 없습니다.")
return done(null, false, { message: '아이디가 다르다' });}
//비밀번호가 다를때
else if (password !== user.password)
return done(null, false, { message: '비번이 다르다' });
else if (password !== user.password) {
//alert("비밀번호가 다릅니다.");
return done(null, false, { message: '비번이 다르다' });}
//아이디, 비밀번호 모두 맞을 경우
return done(null, user);
}
......@@ -87,11 +89,15 @@ passport.authenticate('local', {
//회원가입 페이지 Get
app.get('/join',(req,res)=>{
let page = getPage('회원가입',`
<script> function congratulation()
{
alert("새로운 회원이 되신걸 축하합니다!:D \n 레시피 찾을 준비 되셨나요?");
} </script>
<form action="/join" method="post">
<input type="email" name="email" placeholder="email"><br>
<input type="password" name="password" placeholder="****"><br>
<input type="name" name="name" placeholder="이름"><br>
<input type="submit" value="회원가입"><br>
<input type="submit" value="회원가입" onClick="javascript:congratulation()"><br>
</form>
`,'<a href="/login">뒤로가기</a>');
res.send(page);
......@@ -109,6 +115,7 @@ app.post('/join',(req,res)=>{
//로그 아웃 처리
app.get('/logout',(req,res)=>{
//passport 정보 삭제
req.logout();
//서버측 세션 삭제
......@@ -127,7 +134,7 @@ app.listen(3000,()=>console.log(`http://localhost:3000`));
//로그인 로그아웃 여부
const authInfo = (req)=>{
if(req.user) return `${user.name} | <a href="/logout">로그아웃</a>`;
return `<a href="/login">login</a>`;
return `<a href="/login">로그인</a>`;
}
//페이지 템플릿
......
......@@ -7,6 +7,10 @@ searchForm.addEventListener('submit', function(event){
alert('한글자 이상 입력해주세요');
event.preventDefault();
}
else if(document.getElementById('name').value.length >= 10){
alert('검색어가 너무 깁니다');
event.preventDefault();
}
else{
event.preventDefault();
searchQuery = event.target.querySelector('input').value;
......
{"cookie":{"originalMaxAge":null,"expires":null,"httpOnly":true,"path":"/"},"passport":{"user":"rndus0819@naver.com"},"__lastAccess":1637855607507}
\ No newline at end of file
{"cookie":{"originalMaxAge":null,"expires":null,"httpOnly":true,"path":"/"},"passport":{"user":"rndus0819@naver.com"},"__lastAccess":1637929837064}
\ No newline at end of file