Search code examples
ibm-mobilefirstworklight-adapters

Hydbrid App In IBM Worklight


I Already done updating the password in database using SQLAdpaters in IBM Worklight Hybrid App. I am Working on Hybrid App using IBM Worklight. I am updating user password in database using SQLAdapter, but I want to store password in encrypted format. I already have the encryption and decryption logic in java class. How can I integrate that java class with my hybrid app?

var procedure1Statement = WL.Server.createSQLStatement("UPDATE USERS SET USERPASSWORD=? WHERE USERNAME = ? AND USERPASSWORD=? ");

function updateUserPassword(newPassword,userName,password) {
    return WL.Server.invokeSQLStatement({
        preparedStatement : procedure1Statement,
        parameters : [newPassword,userName,password]
    });
}

Solution

  • changed code as follows

    var userpwdUpdateStatement = WL.Server.createSQLStatement("UPDATE USERS SET USERPASSWORD=? WHERE USERNAME = ? AND USERPASSWORD=? "); 
    
    function updateUserPassword(newPassword,userName,password) { 
      var encryptdecryptutility = new com.abcd.bgf.SysCRAESencrpDecrp(); 
      var encryptnewPassword = encryptdecryptutility.encrypt(newPassword); 
      var encryptoldPassword = encryptdecryptutility.encrypt(password); 
    
      return WL.Server.invokeSQLStatement({ 
          preparedStatement : userpwdUpdateStatement, 
          parameters : [encryptnewPassword,userName,encryptoldPassword] 
      });
    }