mirror of
https://gitlab.com/nekoya/web.git
synced 2024-12-23 06:50:30 +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,28 +126,35 @@ exports.register = async function (req, res) {
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.login = async function (req, res) {
|
exports.login = async function (req, res) {
|
||||||
if (
|
if (!req.body.email || !req.body.password) {
|
||||||
!req.body.email ||
|
// Empty fields
|
||||||
!req.body.password
|
|
||||||
) {
|
|
||||||
// Empty Fields
|
|
||||||
res.render("pages/login-error");
|
res.render("pages/login-error");
|
||||||
} else {
|
} else {
|
||||||
|
var email = req.body.email;
|
||||||
|
var password = req.body.password;
|
||||||
db_connect.query(
|
db_connect.query(
|
||||||
"SELECT * FROM users WHERE email = ?",
|
"SELECT * FROM users WHERE email = ?",
|
||||||
[email],
|
[email],
|
||||||
async function (error, response, fields) {
|
async function (error, response, fields) {
|
||||||
const passCheck = await bcrypt.compare(password, response[0].password);
|
const passCheck = await bcrypt.compare(password, response[0].password);
|
||||||
if (error) {
|
if (error) {
|
||||||
// Error
|
res.send({
|
||||||
res.render("pages/login-error");
|
code: 400,
|
||||||
|
failed: "An error has occured...",
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
if (response.length > 0) {
|
if (response.length > 0) {
|
||||||
if (passCheck) {
|
if (passCheck) {
|
||||||
if (response[0].verify == 0) {
|
if (response[0].verify == 0) {
|
||||||
res.render("pages/login-error");
|
res.send({
|
||||||
|
code: 204,
|
||||||
|
success: "Sorry You havent verified your email",
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
res.render("pages/index");
|
res.send({
|
||||||
|
code: 200,
|
||||||
|
success: "Login Successful!!",
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
res.send({
|
res.send({
|
||||||
|
@ -164,7 +171,7 @@ exports.login = async function (req, res) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* verification email link */
|
/* verification email link */
|
||||||
|
|
Loading…
Reference in a new issue