본문 바로가기

Nodejs

[NODEJS 입문]13.(사용자 DELETE) 사용자 삭제

반응형

 

 

router.route('/user/delete')
.get((req,res)=>{
res.render(path.join('.','user','delete'),{user : req.session.user});
})

 

form(action="/user/delete", method="post")
input(type="hidden", name="_method" value='delete')
input(type="hidden", name="username" value=user.username)
input(type="submit", value="사용자 삭제")

 

 
.delete((req,res)=>{
var temp ={
username : req.body.username,
password : req.body.password,
displayname : req.body.displayname
}
for(var i=0;i<userList.length;i++){
var user = userList[i];
console.log(user,temp);
if(user.username===temp.username){
userList.splice(i,1);
console.log(userList,'이거냐');
delete req.session.displayname;
delete req.session.user;
return req.session.save(()=>{
res.redirect('/user/welcome');
})
}
}
res.redirect('/user/welcome')
})

 

 

반응형