mirror of
https://gitlab.com/nekoya/web.git
synced 2024-12-22 22:45:10 +01:00
Fixed Login error in RegisterLogin.js
This commit is contained in:
parent
fc12e1fe65
commit
e73910b8a0
1 changed files with 35 additions and 28 deletions
|
@ -126,45 +126,52 @@ exports.register = async function (req, res) {
|
|||
};
|
||||
|
||||
exports.login = async function (req, res) {
|
||||
if (
|
||||
!req.body.email ||
|
||||
!req.body.password
|
||||
) {
|
||||
// Empty Fields
|
||||
if (!req.body.email || !req.body.password) {
|
||||
// Empty fields
|
||||
res.render("pages/login-error");
|
||||
} else {
|
||||
db_connect.query(
|
||||
"SELECT * FROM users WHERE email = ?",
|
||||
[email],
|
||||
async function (error, response, fields) {
|
||||
const passCheck = await bcrypt.compare(password, response[0].password);
|
||||
if (error) {
|
||||
// Error
|
||||
res.render("pages/login-error");
|
||||
} else {
|
||||
if (response.length > 0) {
|
||||
if (passCheck) {
|
||||
if (response[0].verify == 0) {
|
||||
res.render("pages/login-error");
|
||||
var email = req.body.email;
|
||||
var password = req.body.password;
|
||||
db_connect.query(
|
||||
"SELECT * FROM users WHERE email = ?",
|
||||
[email],
|
||||
async function (error, response, fields) {
|
||||
const passCheck = await bcrypt.compare(password, response[0].password);
|
||||
if (error) {
|
||||
res.send({
|
||||
code: 400,
|
||||
failed: "An error has occured...",
|
||||
});
|
||||
} else {
|
||||
if (response.length > 0) {
|
||||
if (passCheck) {
|
||||
if (response[0].verify == 0) {
|
||||
res.send({
|
||||
code: 204,
|
||||
success: "Sorry You havent verified your email",
|
||||
});
|
||||
} else {
|
||||
res.send({
|
||||
code: 200,
|
||||
success: "Login Successful!!",
|
||||
});
|
||||
}
|
||||
} else {
|
||||
res.render("pages/index");
|
||||
res.send({
|
||||
code: 204,
|
||||
success: "Sorry Email and password does not match",
|
||||
});
|
||||
}
|
||||
} else {
|
||||
res.send({
|
||||
code: 204,
|
||||
success: "Sorry Email and password does not match",
|
||||
success: "Sorry Email does not exits",
|
||||
});
|
||||
}
|
||||
} else {
|
||||
res.send({
|
||||
code: 204,
|
||||
success: "Sorry Email does not exits",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
/* verification email link */
|
||||
|
|
Loading…
Reference in a new issue