Commit 957b531b authored by Rosanny Sihombing's avatar Rosanny Sihombing
Browse files

update if conditions

parent bc220889
......@@ -68,7 +68,10 @@ var methods = {
getUserByEmail: async function(email) {
try {
let rows = await dbconn.user.promise().query('SELECT id, verificationStatus, salutation, title, firstname, lastname, industry, organisation, speciality, m4lab_idp FROM user WHERE email = "' +email+'"')
return rows[0][0]
if (rows[0][0]) {
return rows[0][0]
}
else { return null }
} catch (err) {
console.error(err)
}
......@@ -77,7 +80,7 @@ var methods = {
getUserEmailById: async function(userId) {
try {
let rows = await dbconn.user.promise().query('SELECT email FROM user WHERE id = ' +userId)
if (rows[0]) {
if (rows[0][0]) {
return rows[0][0].email
}
else { return null }
......@@ -89,7 +92,7 @@ var methods = {
checkUserEmail: async function(email) {
try {
let rows = await dbconn.user.promise().query('SELECT id, email FROM user WHERE email = "' +email+'"')
if (rows[0]) {
if (rows[0][0]) {
return rows[0][0]
}
else { return null }
......@@ -102,7 +105,7 @@ var methods = {
try {
let rows = await dbconn.user.promise().query('SELECT t1.user_id, t2.email FROM userdb.credential AS t1 INNER JOIN userdb.user AS t2 ON t1.user_id = t2.id AND t1.resetPasswordToken = "'
+token+'" and resetPasswordExpires > '+Date.now())
if (rows[0]) {
if (rows[0][0]) {
return rows[0][0]
}
else { return null }
......@@ -152,7 +155,7 @@ var methods = {
getVerificationTokenByUserId: async function(userId) {
try {
let rows = await dbconn.user.promise().query('SELECT token FROM verification WHERE user_id = "' +userId+'"')
if (rows[0]) {
if (rows[0][0]) {
return rows[0][0].token
}
else { return null }
......@@ -164,7 +167,7 @@ var methods = {
getUserIdByVerificationToken: async function(token) {
try {
let rows = await dbconn.user.promise().query('SELECT user_id FROM verification WHERE token = "' +token+'"')
if (rows[0]) {
if (rows[0][0]) {
return rows[0][0].user_id
}
else {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment