diff --git a/modules/Contacts/ContactsHandler.php b/modules/Contacts/ContactsHandler.php index 972f44a2ab9ca8797050239b6a768d5147dee132..54c876936084277c33ac60d05cd6879f4593fe70 100644 --- a/modules/Contacts/ContactsHandler.php +++ b/modules/Contacts/ContactsHandler.php @@ -42,13 +42,13 @@ function Contacts_sendCustomerPortalLoginDetails($entityData){ $password = makeRandomPassword(); $md5_password = md5($password); if ($insert == true) { - $sql = "INSERT INTO vtiger_portalinfo(id,user_name,user_password,type,isactive) VALUES(?,?,?,?,?)"; - $params = array($entityId, $email, $md5_password, 'C', 1); + $sql = "INSERT INTO vtiger_portalinfo(id,user_name,user_password,cryptmode,type,isactive) VALUES(?,?,?,?,?)"; + $params = array($entityId, $email, $md5_password, 'MD5', 'C', 1); $adb->pquery($sql, $params); } if ($update == true && $portalChanged == true) { - $sql = "UPDATE vtiger_portalinfo SET user_password=? WHERE id=?"; - $params = array($md5_password, $entityId); + $sql = "UPDATE vtiger_portalinfo SET user_password=?, cryptmode=? WHERE id=?"; + $params = array($md5_password, 'MD5', $entityId); $adb->pquery($sql, $params); } if (($insert == true || ($update = true && $portalChanged == true)) && $entityData->get('emailoptout') == 0) { diff --git a/modules/Migration/schema/640_to_650.php b/modules/Migration/schema/640_to_650.php index 432024594bba15a8e3d49c76429e8241d3a68934..a62a89bc6c4f9ed4a1120ad3376589adb0eef37e 100644 --- a/modules/Migration/schema/640_to_650.php +++ b/modules/Migration/schema/640_to_650.php @@ -11,14 +11,13 @@ if(defined('VTIGER_UPGRADE')) { //Start add new currency - 'CFP Franc or Pacific Franc' -global $db; +global $adb; + +Vtiger_Utils::AddColumn('vtiger_portalinfo', 'cryptmode', 'varchar(20)'); //Updating existing users password to thier md5 hash +$updateQuery = "UPDATE vtiger_portalinfo SET user_password=MD5(user_password),cryptmode='MD5' WHERE cryptmode is null"; +$adb->pquery($updateQuery, array()); -$selectQuery = 'SELECT 1 FROM vtiger_portalinfo'; -$resultSet = $db->pquery($selectQuery, array()); -if ($db->num_rows($resultSet) > 0) { - $updateQuery = 'UPDATE vtiger_portalinfo SET user_password=MD5(user_password)'; - $db->pquery($updateQuery, array()); } -} \ No newline at end of file + diff --git a/schema/DatabaseSchema.xml b/schema/DatabaseSchema.xml index 9a45daf4c027b220040589ae2f4200aa2d6302f3..08c0f29bf5eb3e42344758725257a9d5b0c9ff45 100644 --- a/schema/DatabaseSchema.xml +++ b/schema/DatabaseSchema.xml @@ -587,6 +587,7 @@ <field name="user_name" type="C" size="50" /> <field name="user_password" type="C" size="30" /> <field name="type" type="C" size="5" /> + <field name="cryptmode" type="C" size="20" /> <field name="last_login_time" type="T" /> <field name="login_time" type="T" /> <field name="logout_time" type="T" />