Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function changePassword(email, newPassword, callback) {
- var oracledb = require('oracledb');
- oracledb.outFormat = oracledb.OBJECT;
- oracledb.getConnection({
- user : '',
- password : '',
- connectString : ''
- },
- function(err, connection) {
- if (err) {
- return callback(new Error(err));
- }
- bcrypt.hash(newPassword, numSaltRounds, function(err, hash) {
- if (err) { return callback(err); }
- connection.execute(
- ' select password as "password" = : hash, ' +
- ' from jsao_users ' +
- ' where email = :email ', [hash, email], { autoCommit: true },
- function(err, result) {
- if (err) {
- console.log(err);
- doRelease(connection);
- return callback(new Error(err));
- }
- doRelease(connection);
- callback(null, result.rowsAffected > 0);
- });
- });
- // Note: connections should always be released when not needed
- function doRelease(connection) {
- connection.close(
- function(err) {
- if (err) {
- console.error(err.message);
- }
- });
- }
- });
- }
- bcrypt.hash(newPassword, numSaltRounds, function(err, hash) { //this is the line
- if (err) { return callback(err); }
- connection.execute(
- ' select password as "password" = : hash, ' +
- ' from jsao_users ' +
- ' where email = :email ', [hash, email], { autoCommit: true },
- function(err, result) {
- if (err) {
- console.log(err);
- doRelease(connection);
- return callback(new Error(err));
- }
- doRelease(connection);
- callback(null, result.rowsAffected > 0);
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement