node js, mongodb 질문드립니다
조회수 482회
비밀번호 분실시 학번 이름 조회해서 db에 있는 이메일로 임시 비밀번호를 보내려고하는데 이메일 조회를 어떻게 해야할지 질문 드립니다 ㅠ
nodejs
models/user.js
User1.getUserByInfo = function (name, username, callback) {
const query = { name: name, username: username };
return User1.findOne(query, {email: 1}, callback);
}
routes/users.js
router.post('/sendmail', (req, res) => {
const name = req.body.name;
const username = req.body.username;
const email = User.getUserByInfo(name, username)
...
Angular
services/auth.service.ts
sendEmail(obj): Observable<Sendmail> {
const sendMail = 'http://localhost:3000/sendmail';
return this.http.post<Sendmail>(sendMail, obj, httpOptions)
}
components/sendmail.compo.ts
var login = {
name: this.name,
username: this.username,
email: ???
}
this.authService.sendEmail(login).subscribe(data => {
this.flashMessage.show('가입한 이메일로 임시 비밀번호 메일을 보냈습니다', {cssClass: 'alert-success', timeout: 5000});
let msg = data['message']
alert(msg);
}, error =>{
console.log(error,"error");
});
댓글 입력