code formatting in auth.service
This commit is contained in:
@@ -48,10 +48,10 @@ async function setTpin(customerNo, tpin) {
|
|||||||
async function setLoginPassword(customerNo, login_psw) {
|
async function setLoginPassword(customerNo, login_psw) {
|
||||||
const hashedLoginPassword = await hashPassword(login_psw);
|
const hashedLoginPassword = await hashPassword(login_psw);
|
||||||
try {
|
try {
|
||||||
await db.query('UPDATE users SET password_hash = $1 ,is_first_login = false WHERE customer_no = $2', [
|
await db.query(
|
||||||
hashedLoginPassword,
|
'UPDATE users SET password_hash = $1 ,is_first_login = false WHERE customer_no = $2',
|
||||||
customerNo,
|
[hashedLoginPassword, customerNo]
|
||||||
]);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`error occured while while setting new Login Password ${error.message}`
|
`error occured while while setting new Login Password ${error.message}`
|
||||||
@@ -62,7 +62,7 @@ async function setLoginPassword(customerNo, login_psw) {
|
|||||||
async function validateTransactionPassword(customerNo, tpassword) {
|
async function validateTransactionPassword(customerNo, tpassword) {
|
||||||
const user = await findUserByCustomerNo(customerNo);
|
const user = await findUserByCustomerNo(customerNo);
|
||||||
if (!user?.transaction_password) return null;
|
if (!user?.transaction_password) return null;
|
||||||
const isMatch = await comparePassword(tpassword, user.transaction_password );
|
const isMatch = await comparePassword(tpassword, user.transaction_password);
|
||||||
return isMatch;
|
return isMatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,10 +70,10 @@ async function validateTransactionPassword(customerNo, tpassword) {
|
|||||||
async function setTransactionPassword(customerNo, trans_psw) {
|
async function setTransactionPassword(customerNo, trans_psw) {
|
||||||
const hashedTransPassword = await hashPassword(trans_psw);
|
const hashedTransPassword = await hashPassword(trans_psw);
|
||||||
try {
|
try {
|
||||||
await db.query('UPDATE users SET transaction_password = $1 WHERE customer_no = $2', [
|
await db.query(
|
||||||
hashedTransPassword,
|
'UPDATE users SET transaction_password = $1 WHERE customer_no = $2',
|
||||||
customerNo,
|
[hashedTransPassword, customerNo]
|
||||||
]);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`error occured while while setting new Transaction Password ${error.message}`
|
`error occured while while setting new Transaction Password ${error.message}`
|
||||||
@@ -81,5 +81,13 @@ async function setTransactionPassword(customerNo, trans_psw) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { validateUser, findUserByCustomerNo, setTpin, validateTpin,
|
module.exports = {
|
||||||
CheckFirstTimeLogin, setLoginPassword, validateTransactionPassword,setTransactionPassword };
|
validateUser,
|
||||||
|
findUserByCustomerNo,
|
||||||
|
setTpin,
|
||||||
|
validateTpin,
|
||||||
|
CheckFirstTimeLogin,
|
||||||
|
setLoginPassword,
|
||||||
|
validateTransactionPassword,
|
||||||
|
setTransactionPassword,
|
||||||
|
};
|
||||||
|
Reference in New Issue
Block a user