0

how can i get the value of the password field using the email provided or retrieved from the login

exports.Authenticate= async function (data){
    try {
            let sql = 'SELECT * FROM "'+config.DDTAA+'"."Users" WHERE "Email"= $1 AND "Password"= $2 AND "Status"=$3';
            const query = await pool.query(sql, [data.Email,data.Password,data.Status]);
            console.log(query)
            // callback - checkout a client
            return pool.query(sql, [data.Email, data.Password,data.Status])
            .then((res) => { return res;})
            .catch((err) => { return console.error('---Error executing query---\n', err.stack) });  
    } catch(err) { return console.error(err); } 
}

this is the result of console.log(query)

enter image description here

user14823468
  • 101
  • 13
  • Sorry, it's not quite clear what you want to do. Do you want to know if the password from an auth request is the same as the one in the DB? – germanio May 13 '21 at 15:57
  • oh, sorry about that, i am not good in english. , yes thats right. – user14823468 May 13 '21 at 15:58
  • I just want to compare the login password to db password – user14823468 May 13 '21 at 15:58
  • ohh cool, yeah no problem. To compare the two, you need to compare their hashes. So you should hash the password in the request with the same algorithm used with the one in the DB. – germanio May 13 '21 at 16:01
  • take a look at this, for instance: https://stackoverflow.com/questions/116684/what-algorithm-should-i-use-to-hash-passwords-into-my-database – germanio May 13 '21 at 16:03
  • yes exactly !! can you please show me the solutions please? – user14823468 May 13 '21 at 16:03
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/232355/discussion-between-germanio-and-user14823468). – germanio May 13 '21 at 16:04

0 Answers0