[英]Trying to create a login with mongodb
我正在尝试检查用户在登录表单中输入的详细信息是否与 mongodb 数据 egemail 和密码匹配。但是此功能不起作用。 当用户输入正确的信息时,它应该将他们引导到主页。
const logindetails = new Vue({
el: '#logindetails',
data: {
errors: [],
email: "",
passwordInput: ""
},
methods: {
login: function () {
var account = db.collection('users')(userdetails.email === userdetails.email &&
userdetails.passwordInput === userdetails.password) ? userdetails : null;
});
if (account) {
window.location.href = "welcomepage.html?email=" + account.email;
} else {
alert("Email/Password has not been identified.");
}
}
}
});
在尝试重新格式化您的问题以删除 HTML 时,我注意到您有几个不匹配的括号。
你有一个额外的行});
在阻止您的login
功能进入if
语句的代码中。
正确的缩进可以帮助您发现这样的错误。
这是已删除行的更正代码。
const logindetails = new Vue({
el: '#logindetails',
data: {
errors: [],
email: "",
passwordInput: ""
},
methods: {
login: function () {
var account = db.collection('users')(userdetails.email === userdetails.email &&
userdetails.passwordInput === userdetails.password) ? userdetails : null;
if (account) {
window.location.href = "welcomepage.html?email=" + account.email;
} else {
alert("Email/Password has not been identified.");
}
}
}
});
这是原始代码,问题行旁边有注释
const logindetails = new Vue({
el: '#logindetails',
data: {
errors: [],
email: "",
passwordInput: ""
},
methods: {
login: function () {
var account = db.collection('users')(userdetails.email === userdetails.email &&
userdetails.passwordInput === userdetails.password) ? userdetails : null;
}); //<-- looks wrong, stops 'login' function
if (account) {
window.location.href = "welcomepage.html?email=" + account.email;
} else {
alert("Email/Password has not been identified.");
}
}
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.