Skip to content

Commit

Permalink
Added a substr to limit paswword length at user creation
Browse files Browse the repository at this point in the history
Set version to 4.0.3
  • Loading branch information
tomolimo committed Apr 26, 2021
1 parent 8e7cf28 commit 4e0250b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
9 changes: 2 additions & 7 deletions inc/processmaker.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,17 +271,12 @@ function login($admin_or_user = false, $case_guid = 'default') {
// get user from glpi_plugin_processmaker_users table
$pmusr = new PluginProcessmakerUser;
$pmusr->getFromDB($gusr->getID());
//if (!isset($pmusr->fields['password']) || $pmusr->fields['password'] == "") {
if (is_object($pmusr) && array_key_exists('pm_users_id', $pmusr->fields)) {
$pass = md5(Toolbox::sodiumEncrypt($gusr->getID().$gusr->getName().time()));
//$pmusr->update( array('id' => $pmusr->getID(), 'password' => $pass) );
// and must be updated also in PM db
$PM_DB->update('RBAC_USERS', ['USR_PASSWORD' => $pass], ['USR_UID' => $pmusr->fields['pm_users_id']]);
//$PM_DB->query("UPDATE RBAC_USERS SET USR_PASSWORD='".$pass."' WHERE USR_UID='".$pmusr->fields['pm_users_id']."' ");
$PM_DB->update('USERS', ['USR_PASSWORD' => $pass], ['USR_UID' => $pmusr->fields['pm_users_id']]);
//$PM_DB->query("UPDATE USERS SET USR_PASSWORD='".$pass."' WHERE USR_UID='".$pmusr->fields['pm_users_id']."' ");
//}
//$locSession = $this->pmSoapClient->login( array( 'userid' => $gusr->fields['name'], 'password' => 'md5:'.$pmusr->fields['password']) );
// and then login with this user/password
$locSession = $this->pmSoapClient->login( ['userid' => $gusr->fields['name'], 'password' => 'md5:'.$pass] );
if (is_object( $locSession ) && $locSession->status_code == 0) {
$_SESSION["pluginprocessmaker"]["session"]["id"] = $locSession->message;
Expand Down Expand Up @@ -1313,7 +1308,7 @@ static function cronPMUsers($task) {
if ($user['is_active'] != 0 && $user['is_deleted'] != 1) {
$status = "ACTIVE";
$task->addVolume(1);
$pass = md5(Toolbox::sodiumEncrypt($user['id'].$user['name'].time()));
$pass = substr(Toolbox::sodiumEncrypt($user['id'].$user['name'].time()), 0, 20); // must keep only 20 chars as the web service is limited to 20 for the password
$pmResult = $PM_SOAP->createUser($user['name'], $user['firstname'], $user['realname'], "", "PROCESSMAKER_OPERATOR", $pass, $status);
if ($pmResult->status_code == 0) {
$task->log( "Added user: '".$user['name']."'" );
Expand Down
2 changes: 1 addition & 1 deletion processmaker.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<compatibility>9.4</compatibility>
</version>
<version>
<num>4.0.2</num>
<num>4.0.3</num>
<compatibility>9.5</compatibility>
</version>
</versions>
Expand Down
2 changes: 1 addition & 1 deletion setup.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

define('PROCESSMAKER_VERSION', '4.0.2');
define('PROCESSMAKER_VERSION', '4.0.3');

// used for case cancellation
define("CANCEL", 256);
Expand Down

0 comments on commit 4e0250b

Please sign in to comment.