2010-12-02 23:34:41 +00:00
|
|
|
<?php
|
|
|
|
|
|
2019-04-15 14:02:16 -04:00
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
|
use ProcessMaker\BusinessModel\User;
|
2017-08-14 16:13:46 -04:00
|
|
|
use ProcessMaker\Core\System;
|
2017-08-01 12:16:06 -04:00
|
|
|
use ProcessMaker\Plugins\PluginRegistry;
|
|
|
|
|
|
2010-12-02 23:34:41 +00:00
|
|
|
try {
|
2015-11-27 15:38:27 -04:00
|
|
|
$usr = '';
|
|
|
|
|
$pwd = '';
|
|
|
|
|
|
|
|
|
|
if (strpos($_SERVER['HTTP_REFERER'], 'home/login') !== false) {
|
|
|
|
|
$urlLogin = '../home/login';
|
|
|
|
|
} else {
|
|
|
|
|
$urlLogin = (substr(SYS_SKIN, 0, 2) !== 'ux')? 'login' : '../main/login';
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-26 15:58:35 +00:00
|
|
|
$cookieOptions = Bootstrap::buildCookieOptions(['expires' => time() + (24 * 60 * 60)]);
|
2012-07-04 19:01:31 -04:00
|
|
|
if (!$RBAC->singleSignOn) {
|
2021-11-26 15:58:35 +00:00
|
|
|
setcookie('singleSignOn', '0', $cookieOptions);
|
2012-07-04 19:01:31 -04:00
|
|
|
if (!isset($_POST['form']) ) {
|
|
|
|
|
G::SendTemporalMessage ('ID_USER_HAVENT_RIGHTS_SYSTEM', 'error');
|
|
|
|
|
G::header('Location: login');
|
|
|
|
|
die();
|
|
|
|
|
}
|
2011-08-24 19:30:03 -04:00
|
|
|
|
2012-07-04 19:01:31 -04:00
|
|
|
$frm = $_POST['form'];
|
2011-08-24 19:34:44 -04:00
|
|
|
|
2019-04-15 14:02:16 -04:00
|
|
|
$changePassword = false;
|
|
|
|
|
if (isset($_POST['form']['__USR_PASSWORD_CHANGE__'])) {
|
|
|
|
|
$value = Cache::pull($_POST['form']['__USR_PASSWORD_CHANGE__']);
|
|
|
|
|
$changePassword = !empty($value);
|
|
|
|
|
if ($changePassword === true) {
|
|
|
|
|
$_POST['form']['USER_ENV'] = $value['userEnvironment'];
|
|
|
|
|
$_POST['form']['BROWSER_TIME_ZONE_OFFSET'] = $value['browserTimeZoneOffset'];
|
|
|
|
|
$frm['USR_USERNAME'] = $value['usrUsername'];
|
|
|
|
|
$frm['USR_PASSWORD'] = $value['usrPassword'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-04 19:01:31 -04:00
|
|
|
if (isset($frm['USR_USERNAME'])) {
|
2013-01-02 11:53:19 -04:00
|
|
|
$usr = mb_strtolower(trim($frm['USR_USERNAME']), 'UTF-8');
|
2012-07-04 19:01:31 -04:00
|
|
|
$pwd = trim($frm['USR_PASSWORD']);
|
|
|
|
|
}
|
2014-11-24 11:06:28 -04:00
|
|
|
/*----------------------------------********---------------------------------*/
|
2014-09-22 09:58:50 -04:00
|
|
|
require_once PATH_CORE . 'methods' . PATH_SEP . 'enterprise' . PATH_SEP . 'enterprise.php';
|
|
|
|
|
|
|
|
|
|
if (!file_exists(PATH_DATA_SITE . "plugin.singleton")) {
|
2014-09-25 16:55:16 -04:00
|
|
|
$enterprise = new enterprisePlugin('enterprise');
|
2014-09-22 09:58:50 -04:00
|
|
|
$enterprise->enable();
|
2014-09-25 16:55:16 -04:00
|
|
|
$enterprise->setup();
|
2014-09-22 09:58:50 -04:00
|
|
|
}
|
2014-11-24 11:06:28 -04:00
|
|
|
/*----------------------------------********---------------------------------*/
|
2020-10-07 22:59:04 -04:00
|
|
|
Cache::put('ldapMessageError', '', 2);
|
|
|
|
|
$uid = $RBAC->VerifyLogin($usr, $pwd);
|
|
|
|
|
$ldapMessageError = Cache::pull('ldapMessageError');
|
2012-07-04 19:01:31 -04:00
|
|
|
$RBAC->cleanSessionFiles(72); //cleaning session files older than 72 hours
|
|
|
|
|
|
|
|
|
|
switch ($uid) {
|
|
|
|
|
//The user does doesn't exist
|
|
|
|
|
case -1:
|
2013-03-04 11:32:49 -04:00
|
|
|
$errLabel = 'WRONG_LOGIN_CREDENTIALS';
|
2012-07-04 19:01:31 -04:00
|
|
|
break;
|
|
|
|
|
//The password is incorrect
|
|
|
|
|
case -2:
|
2013-03-04 11:32:49 -04:00
|
|
|
$errLabel = 'WRONG_LOGIN_CREDENTIALS';
|
2012-07-04 19:01:31 -04:00
|
|
|
if (isset($_SESSION['__AUTH_ERROR__'])) {
|
|
|
|
|
G::SendMessageText($_SESSION['__AUTH_ERROR__'], "warning");
|
|
|
|
|
unset($_SESSION['__AUTH_ERROR__']);
|
2014-07-03 10:32:25 -04:00
|
|
|
}
|
2012-07-04 19:01:31 -04:00
|
|
|
break;
|
|
|
|
|
//The user is inactive
|
|
|
|
|
case -3:
|
|
|
|
|
require_once 'classes/model/Users.php';
|
2012-09-13 14:54:38 -04:00
|
|
|
$user = new Users();
|
2012-07-04 19:01:31 -04:00
|
|
|
$aUser = $user->loadByUsernameInArray($usr);
|
2012-02-24 19:32:24 -04:00
|
|
|
|
2012-07-04 19:01:31 -04:00
|
|
|
switch ($aUser['USR_STATUS']) {
|
|
|
|
|
case 'VACATION':
|
2012-09-13 14:54:38 -04:00
|
|
|
$uid = $aUser['USR_UID'];
|
|
|
|
|
$RBAC->changeUserStatus($uid, 1);
|
|
|
|
|
$aUser['USR_STATUS'] = 'ACTIVE';
|
|
|
|
|
$user->update($aUser);
|
2012-07-04 19:01:31 -04:00
|
|
|
break;
|
|
|
|
|
case 'INACTIVE':
|
|
|
|
|
$errLabel = 'ID_USER_INACTIVE';
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
//The Due date is finished
|
|
|
|
|
case -4:
|
|
|
|
|
$errLabel = 'ID_USER_INACTIVE_BY_DATE';
|
|
|
|
|
break;
|
|
|
|
|
case -5:
|
|
|
|
|
$errLabel = 'ID_AUTHENTICATION_SOURCE_INVALID';
|
|
|
|
|
break;
|
2013-12-09 14:58:41 -04:00
|
|
|
case -6:
|
|
|
|
|
$errLabel = 'ID_ROLE_INACTIVE';
|
|
|
|
|
break;
|
2014-12-03 13:42:09 -04:00
|
|
|
case -7:
|
|
|
|
|
$errLabel = 'ID_LECA';
|
|
|
|
|
break;
|
2011-08-24 19:30:03 -04:00
|
|
|
}
|
2012-02-24 19:32:24 -04:00
|
|
|
|
2012-07-04 19:01:31 -04:00
|
|
|
//to avoid empty string in user field. This will avoid a weird message "this row doesn't exist"
|
|
|
|
|
if ( !isset($uid) ) {
|
|
|
|
|
$uid = -1;
|
2013-03-04 11:32:49 -04:00
|
|
|
$errLabel = 'WRONG_LOGIN_CREDENTIALS';
|
2011-08-24 19:30:03 -04:00
|
|
|
}
|
2012-02-24 19:32:24 -04:00
|
|
|
|
2014-09-23 17:16:31 -04:00
|
|
|
$_SESSION["USERNAME_PREVIOUS1"] = (isset($_SESSION["USERNAME_PREVIOUS2"]))? $_SESSION["USERNAME_PREVIOUS2"] : "";
|
2014-09-19 10:45:24 -04:00
|
|
|
$_SESSION["USERNAME_PREVIOUS2"] = $usr;
|
2016-09-15 11:53:35 -04:00
|
|
|
$_SESSION["FAILED_LOGINS"] = (isset($frm['FAILED_LOGINS']))? $frm['FAILED_LOGINS'] : 0;
|
2014-09-19 10:45:24 -04:00
|
|
|
|
2012-07-04 19:01:31 -04:00
|
|
|
if (!isset($uid) || $uid < 0) {
|
2014-09-19 10:45:24 -04:00
|
|
|
if ($_SESSION["USERNAME_PREVIOUS1"] != "" && $_SESSION["USERNAME_PREVIOUS2"] != "" && $_SESSION["USERNAME_PREVIOUS1"] != $_SESSION["USERNAME_PREVIOUS2"]) {
|
|
|
|
|
$_SESSION["FAILED_LOGINS"] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-11 12:07:24 -04:00
|
|
|
if (isset($_SESSION['FAILED_LOGINS']) && ($uid == -1 || $uid == -2)) {
|
2012-07-04 19:01:31 -04:00
|
|
|
$_SESSION['FAILED_LOGINS']++;
|
|
|
|
|
}
|
|
|
|
|
if (!defined('PPP_FAILED_LOGINS')) {
|
|
|
|
|
define('PPP_FAILED_LOGINS', 0);
|
|
|
|
|
}
|
|
|
|
|
if (PPP_FAILED_LOGINS > 0) {
|
|
|
|
|
if ($_SESSION['FAILED_LOGINS'] >= PPP_FAILED_LOGINS) {
|
|
|
|
|
$oConnection = Propel::getConnection('rbac');
|
2014-09-17 10:57:33 -04:00
|
|
|
$oStatement = $oConnection->prepareStatement("SELECT USR_UID FROM RBAC_USERS WHERE USR_USERNAME = '" . $usr . "'");
|
2012-07-04 19:01:31 -04:00
|
|
|
$oDataset = $oStatement->executeQuery();
|
|
|
|
|
if ($oDataset->next()) {
|
|
|
|
|
$sUserUID = $oDataset->getString('USR_UID');
|
|
|
|
|
$oConnection = Propel::getConnection('rbac');
|
2014-09-17 10:57:33 -04:00
|
|
|
$oStatement = $oConnection->prepareStatement("UPDATE RBAC_USERS SET USR_STATUS = 0 WHERE USR_UID = '" . $sUserUID . "'");
|
2012-07-04 19:01:31 -04:00
|
|
|
$oStatement->executeQuery();
|
|
|
|
|
$oConnection = Propel::getConnection('workflow');
|
|
|
|
|
$oStatement = $oConnection->prepareStatement("UPDATE USERS SET USR_STATUS = 'INACTIVE' WHERE USR_UID = '" . $sUserUID . "'");
|
|
|
|
|
$oStatement->executeQuery();
|
|
|
|
|
unset($_SESSION['FAILED_LOGINS']);
|
2014-07-11 12:07:24 -04:00
|
|
|
$errLabel = G::LoadTranslation('ID_ACCOUNT') . ' "' . $usr . '" ' . G::LoadTranslation('ID_ACCOUNT_DISABLED_CONTACT_ADMIN');
|
2012-07-04 19:01:31 -04:00
|
|
|
}
|
2014-07-11 12:07:24 -04:00
|
|
|
//Log failed authentications
|
2017-10-10 12:33:25 -04:00
|
|
|
$message = "| Many failed authentication attempts for USER: " . $usr . " | IP: " . G::getIpAddress() . " | WS: " . config("system.workspace");
|
2014-10-03 11:09:45 -04:00
|
|
|
$message .= " | BROWSER: " . $_SERVER['HTTP_USER_AGENT'];
|
2014-07-11 12:07:24 -04:00
|
|
|
|
|
|
|
|
G::log($message, PATH_DATA, 'loginFailed.log');
|
2012-07-04 19:01:31 -04:00
|
|
|
}
|
|
|
|
|
}
|
2011-08-24 19:30:03 -04:00
|
|
|
|
2012-07-04 19:01:31 -04:00
|
|
|
if (strpos($_SERVER['HTTP_REFERER'], 'home/login') !== false) {
|
2015-11-27 15:38:27 -04:00
|
|
|
$d = serialize(['u' => $usr, 'p' => $pwd, 'm' => G::LoadTranslation($errLabel)]);
|
|
|
|
|
$urlLogin = $urlLogin . '?d=' . base64_encode($d);
|
2012-07-04 19:01:31 -04:00
|
|
|
} else {
|
2020-10-07 22:59:04 -04:00
|
|
|
if (empty($ldapMessageError)) {
|
|
|
|
|
G::SendTemporalMessage($errLabel, "warning");
|
|
|
|
|
} else {
|
|
|
|
|
G::SendTemporalMessage($ldapMessageError, "warning", "string");
|
|
|
|
|
}
|
2012-07-04 19:01:31 -04:00
|
|
|
}
|
|
|
|
|
|
2016-08-17 17:04:14 -04:00
|
|
|
$u = (array_key_exists('form', $_POST) && array_key_exists('URL', $_POST['form']))? 'u=' . urlencode(htmlspecialchars_decode($_POST['form']['URL'])) : '';
|
2016-07-28 18:27:20 -04:00
|
|
|
|
|
|
|
|
if ($u != '') {
|
|
|
|
|
$urlLogin = $urlLogin . ((preg_match('/^.+\?.+$/', $urlLogin))? '&' : '?') . $u;
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-27 15:38:27 -04:00
|
|
|
G::header('Location: ' . $urlLogin);
|
|
|
|
|
exit(0);
|
2012-03-29 16:42:09 -04:00
|
|
|
}
|
2012-02-24 19:32:24 -04:00
|
|
|
|
2012-07-04 19:01:31 -04:00
|
|
|
if (!isset( $_SESSION['WORKSPACE'] ) ) {
|
2017-10-10 12:33:25 -04:00
|
|
|
$_SESSION['WORKSPACE'] = config("system.workspace");
|
2012-07-04 19:01:31 -04:00
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-07-04 19:01:31 -04:00
|
|
|
//Execute the SSO Script from plugin
|
2017-08-01 12:16:06 -04:00
|
|
|
$oPluginRegistry = PluginRegistry::loadSingleton();
|
2014-09-25 16:55:16 -04:00
|
|
|
$lSession="";
|
|
|
|
|
$loginInfo = new loginInfo ($usr, $pwd, $lSession );
|
2012-07-04 19:01:31 -04:00
|
|
|
if ($oPluginRegistry->existsTrigger ( PM_LOGIN )) {
|
|
|
|
|
$oPluginRegistry->executeTriggers ( PM_LOGIN , $loginInfo );
|
|
|
|
|
}
|
2017-08-11 15:11:24 -04:00
|
|
|
EnterpriseClass::enterpriseSystemUpdate($loginInfo);
|
2017-10-13 07:57:22 -04:00
|
|
|
initUserSession($uid, $usr);
|
2012-07-04 19:01:31 -04:00
|
|
|
} else {
|
2021-11-26 15:58:35 +00:00
|
|
|
setcookie('singleSignOn', '1', $cookieOptions);
|
2012-07-04 19:01:31 -04:00
|
|
|
$uid = $RBAC->userObj->fields['USR_UID'];
|
|
|
|
|
$usr = $RBAC->userObj->fields['USR_USERNAME'];
|
2017-10-13 07:57:22 -04:00
|
|
|
initUserSession($uid, $usr);
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
2015-12-09 17:33:31 -04:00
|
|
|
//Set default Languaje
|
|
|
|
|
if (isset($frm['USER_LANG'])) {
|
|
|
|
|
if ($frm['USER_LANG'] != '') {
|
|
|
|
|
$lang = $frm['USER_LANG'];
|
|
|
|
|
if($frm['USER_LANG'] == "default"){
|
|
|
|
|
//Check the USR_DEFAULT_LANG
|
|
|
|
|
require_once 'classes/model/Users.php';
|
|
|
|
|
$user = new Users();
|
|
|
|
|
$rsUser = $user->userLanguaje($_SESSION['USER_LOGGED']);
|
|
|
|
|
$rsUser->next();
|
|
|
|
|
$rowUser = $rsUser->getRow();
|
|
|
|
|
if( isset($rowUser["USR_DEFAULT_LANG"]) && $rowUser["USR_DEFAULT_LANG"]!=''){
|
|
|
|
|
$lang = $rowUser["USR_DEFAULT_LANG"];
|
|
|
|
|
} else {
|
|
|
|
|
//Check the login_defaultLanguage
|
|
|
|
|
$oConf = new Configurations();
|
|
|
|
|
$oConf->loadConfig($obj, 'ENVIRONMENT_SETTINGS', '');
|
|
|
|
|
if (isset($oConf->aConfig["login_defaultLanguage"]) && $oConf->aConfig["login_defaultLanguage"] != "") {
|
|
|
|
|
$lang = $oConf->aConfig["login_defaultLanguage"];
|
|
|
|
|
}else{
|
|
|
|
|
if(SYS_LANG != ''){
|
|
|
|
|
$lang = SYS_LANG;
|
|
|
|
|
}else{
|
|
|
|
|
$lang = 'en';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$lang = $frm['USER_LANG'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (defined("SYS_LANG") && SYS_LANG != "") {
|
|
|
|
|
$lang = SYS_LANG;
|
|
|
|
|
} else {
|
|
|
|
|
$lang = 'en';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-26 20:11:58 -04:00
|
|
|
//Set User Time Zone
|
|
|
|
|
$user = UsersPeer::retrieveByPK($_SESSION['USER_LOGGED']);
|
|
|
|
|
|
|
|
|
|
if (!is_null($user)) {
|
|
|
|
|
$userTimeZone = $user->getUsrTimeZone();
|
|
|
|
|
|
|
|
|
|
if (trim($userTimeZone) == '') {
|
2017-10-10 12:33:25 -04:00
|
|
|
$arraySystemConfiguration = System::getSystemConfiguration('', '', config("system.workspace"));
|
2015-11-26 20:11:58 -04:00
|
|
|
|
|
|
|
|
$userTimeZone = $arraySystemConfiguration['time_zone'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$_SESSION['USR_TIME_ZONE'] = $userTimeZone;
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-04 16:43:45 -04:00
|
|
|
/*----------------------------------********---------------------------------*/
|
|
|
|
|
if (PMLicensedFeatures::getSingleton()->verifyfeature('oq3S29xemxEZXJpZEIzN01qenJUaStSekY4cTdJVm5vbWtVM0d4S2lJSS9qUT0=')) {
|
|
|
|
|
if (isset($_SESSION['__SYSTEM_UTC_TIME_ZONE__']) && $_SESSION['__SYSTEM_UTC_TIME_ZONE__']) {
|
|
|
|
|
$dateTime = new \ProcessMaker\Util\DateTime();
|
2015-11-27 15:38:27 -04:00
|
|
|
|
2015-12-04 16:43:45 -04:00
|
|
|
$timeZoneOffset = $dateTime->getTimeZoneOffsetByTimeZoneId($_SESSION['USR_TIME_ZONE']);
|
2015-11-27 15:38:27 -04:00
|
|
|
|
2015-12-04 16:43:45 -04:00
|
|
|
if ($timeZoneOffset === false || $timeZoneOffset != (int)($_POST['form']['BROWSER_TIME_ZONE_OFFSET'])) {
|
|
|
|
|
$_SESSION['__TIME_ZONE_FAILED__'] = true;
|
2018-06-04 14:39:57 -04:00
|
|
|
$_SESSION['BROWSER_TIME_ZONE'] = $dateTime->getTimeZoneIdByTimeZoneOffset((int)$_POST['form']['BROWSER_TIME_ZONE_OFFSET'], false);
|
2015-12-04 16:43:45 -04:00
|
|
|
}
|
2015-11-27 15:38:27 -04:00
|
|
|
}
|
|
|
|
|
}
|
2015-12-04 16:43:45 -04:00
|
|
|
/*----------------------------------********---------------------------------*/
|
2015-11-27 15:38:27 -04:00
|
|
|
|
2015-11-26 20:11:58 -04:00
|
|
|
//Set data
|
2012-07-04 19:01:31 -04:00
|
|
|
$aUser = $RBAC->userObj->load($_SESSION['USER_LOGGED']);
|
|
|
|
|
$RBAC->loadUserRolePermission($RBAC->sSystem, $_SESSION['USER_LOGGED']);
|
|
|
|
|
//$rol = $RBAC->rolesObj->load($RBAC->aUserInfo['PROCESSMAKER']['ROLE']['ROL_UID']);
|
|
|
|
|
$_SESSION['USR_FULLNAME'] = $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'];
|
|
|
|
|
//$_SESSION['USR_ROLENAME'] = $rol['ROL_NAME'];
|
2011-08-24 19:30:03 -04:00
|
|
|
|
2012-07-04 19:01:31 -04:00
|
|
|
unset($_SESSION['FAILED_LOGINS']);
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-07-04 19:01:31 -04:00
|
|
|
// Assign the uid of user to userloggedobj
|
|
|
|
|
$RBAC->loadUserRolePermission($RBAC->sSystem, $uid);
|
2017-10-05 12:20:25 -04:00
|
|
|
$res = $RBAC->userCanAccess('PM_LOGIN/strict');
|
2012-07-04 19:01:31 -04:00
|
|
|
if ($res != 1 ) {
|
|
|
|
|
if ($res == -2) {
|
|
|
|
|
G::SendTemporalMessage ('ID_USER_HAVENT_RIGHTS_SYSTEM', "error");
|
|
|
|
|
} else {
|
|
|
|
|
G::SendTemporalMessage ('ID_USER_HAVENT_RIGHTS_PAGE', "error");
|
|
|
|
|
}
|
|
|
|
|
G::header ("location: login.html");
|
|
|
|
|
die;
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2012-07-04 19:01:31 -04:00
|
|
|
|
|
|
|
|
/**log in table Login**/
|
|
|
|
|
require_once 'classes/model/LoginLog.php';
|
|
|
|
|
$weblog=new LoginLog();
|
|
|
|
|
$aLog['LOG_UID'] = G::generateUniqueID();
|
|
|
|
|
$aLog['LOG_STATUS'] = 'ACTIVE';
|
2014-03-27 10:09:35 -04:00
|
|
|
$aLog['LOG_IP'] = G::getIpAddress();
|
2012-07-04 19:01:31 -04:00
|
|
|
$aLog['LOG_SID'] = session_id();
|
|
|
|
|
$aLog['LOG_INIT_DATE'] = date('Y-m-d H:i:s');
|
|
|
|
|
//$aLog['LOG_END_DATE'] = '0000-00-00 00:00:00';
|
2018-10-19 17:01:49 -04:00
|
|
|
$aLog['LOG_CLIENT_HOSTNAME']= System::getServerHost();
|
2012-07-04 19:01:31 -04:00
|
|
|
$aLog['USR_UID'] = $_SESSION['USER_LOGGED'];
|
|
|
|
|
$weblog->create($aLog);
|
|
|
|
|
/**end log**/
|
2011-08-24 19:30:03 -04:00
|
|
|
|
2012-07-04 19:01:31 -04:00
|
|
|
//**** defining and saving server info, this file has the values of the global array $_SERVER ****
|
|
|
|
|
//this file is useful for command line environment (no Browser), I mean for triggers, crons and other executed over command line
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-07-04 19:01:31 -04:00
|
|
|
$_CSERVER = $_SERVER;
|
|
|
|
|
unset($_CSERVER['REQUEST_TIME']);
|
|
|
|
|
unset($_CSERVER['REMOTE_PORT']);
|
|
|
|
|
$cput = serialize($_CSERVER);
|
2015-05-10 17:16:34 -04:00
|
|
|
if (!is_file(PATH_DATA_SITE . '.server_info')) {
|
|
|
|
|
file_put_contents(PATH_DATA_SITE . '.server_info', $cput);
|
2012-07-04 19:01:31 -04:00
|
|
|
} else {
|
2015-05-10 17:16:34 -04:00
|
|
|
$c = file_get_contents(PATH_DATA_SITE . '.server_info');
|
2015-03-25 16:22:18 -04:00
|
|
|
if (G::encryptOld($c) != G::encryptOld($cput)) {
|
2015-05-10 17:16:34 -04:00
|
|
|
file_put_contents(PATH_DATA_SITE . '.server_info', $cput);
|
2012-07-04 19:01:31 -04:00
|
|
|
}
|
2012-04-05 12:52:33 -04:00
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-07-04 19:01:31 -04:00
|
|
|
/* Check password using policy - Start */
|
|
|
|
|
require_once 'classes/model/UsersProperties.php';
|
2018-10-26 16:14:37 -04:00
|
|
|
$userProperty = new UsersProperties();
|
2011-10-11 18:33:06 -04:00
|
|
|
|
2012-07-04 19:01:31 -04:00
|
|
|
// getting default user location
|
|
|
|
|
if (isset($_REQUEST['form']['URL']) && $_REQUEST['form']['URL'] != '') {
|
2013-01-08 13:21:40 -04:00
|
|
|
if (isset($_SERVER['HTTP_REFERER'])) {
|
|
|
|
|
if (strpos($_SERVER['HTTP_REFERER'], 'processes/processes_Map?PRO_UID=') !== false) {
|
|
|
|
|
$sLocation = $_SERVER['HTTP_REFERER'];
|
|
|
|
|
} else {
|
2013-11-15 15:29:07 -04:00
|
|
|
$sLocation = G::sanitizeInput($_REQUEST['form']['URL']);
|
2013-01-08 13:21:40 -04:00
|
|
|
}
|
|
|
|
|
} else {
|
2013-11-15 15:29:07 -04:00
|
|
|
$sLocation = G::sanitizeInput($_REQUEST['form']['URL']);
|
2013-01-08 13:21:40 -04:00
|
|
|
}
|
2012-07-04 19:01:31 -04:00
|
|
|
} else {
|
|
|
|
|
if (isset($_REQUEST['u']) && $_REQUEST['u'] != '') {
|
2013-11-15 15:29:07 -04:00
|
|
|
$sLocation = G::sanitizeInput($_REQUEST['u']);
|
2012-07-04 19:01:31 -04:00
|
|
|
} else {
|
2018-10-26 16:14:37 -04:00
|
|
|
$sLocation = $userProperty->redirectTo($_SESSION['USER_LOGGED'], $lang);
|
2012-07-04 19:01:31 -04:00
|
|
|
}
|
2011-10-10 12:14:38 -04:00
|
|
|
}
|
2012-07-04 19:01:31 -04:00
|
|
|
|
|
|
|
|
if ($RBAC->singleSignOn) {
|
2019-07-05 16:00:43 -04:00
|
|
|
// Update the User's last login date
|
|
|
|
|
updateUserLastLogin($aLog);
|
2012-07-04 19:01:31 -04:00
|
|
|
G::header('Location: ' . $sLocation);
|
|
|
|
|
die();
|
2011-10-10 12:14:38 -04:00
|
|
|
}
|
2012-04-05 12:52:33 -04:00
|
|
|
|
2018-10-26 16:14:37 -04:00
|
|
|
$userPropertyInfo = $userProperty->loadOrCreateIfNotExists($_SESSION['USER_LOGGED'], array('USR_PASSWORD_HISTORY' => serialize(array(G::encryptOld($pwd)))));
|
2019-04-15 14:02:16 -04:00
|
|
|
|
|
|
|
|
//change password
|
|
|
|
|
if ($changePassword === true) {
|
|
|
|
|
$user = new User();
|
|
|
|
|
$currentUser = $user->changePassword($_SESSION['USER_LOGGED'], $_POST['form']['USR_PASSWORD']);
|
2019-07-05 16:00:43 -04:00
|
|
|
// Update the User's last login date
|
|
|
|
|
updateUserLastLogin($aLog);
|
2019-04-15 14:02:16 -04:00
|
|
|
G::header('Location: ' . $currentUser["__REDIRECT_PATH__"]);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-11 07:48:44 -04:00
|
|
|
//Get the errors in the password
|
2018-10-26 16:14:37 -04:00
|
|
|
$errorInPassword = $userProperty->validatePassword(
|
|
|
|
|
$_POST['form']['USR_PASSWORD'],
|
|
|
|
|
$userPropertyInfo['USR_LAST_UPDATE_DATE'],
|
|
|
|
|
$userPropertyInfo['USR_LOGGED_NEXT_TIME']
|
|
|
|
|
);
|
2020-10-01 20:13:13 -04:00
|
|
|
//The other authentication methods should not be validated by password security policies.
|
|
|
|
|
if (!empty($aUser['USR_AUTH_TYPE'])) {
|
|
|
|
|
$authType = $aUser['USR_AUTH_TYPE'];
|
|
|
|
|
if ($authType != "mysql" && $authType != "") {
|
|
|
|
|
$policiesToExclude = [
|
|
|
|
|
'ID_PPP_MINIMUM_LENGTH',
|
|
|
|
|
'ID_PPP_MAXIMUM_LENGTH',
|
|
|
|
|
'ID_PPP_NUMERICAL_CHARACTER_REQUIRED',
|
|
|
|
|
'ID_PPP_UPPERCASE_CHARACTER_REQUIRED',
|
|
|
|
|
'ID_PPP_SPECIAL_CHARACTER_REQUIRED'
|
|
|
|
|
];
|
|
|
|
|
$errorInPassword = array_diff($errorInPassword, $policiesToExclude);
|
|
|
|
|
$errorInPassword = array_values($errorInPassword);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-12-11 07:48:44 -04:00
|
|
|
//Get the policies enabled
|
|
|
|
|
$policiesInPassword = $userProperty->validatePassword('', date('Y-m-d'), $userPropertyInfo['USR_LOGGED_NEXT_TIME'], true);
|
2018-10-26 16:14:37 -04:00
|
|
|
//Enable change password from GAP
|
2018-10-11 12:19:57 -04:00
|
|
|
if (!isset($enableChangePasswordAfterNextLogin)) {
|
|
|
|
|
$enableChangePasswordAfterNextLogin = true;
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-26 16:14:37 -04:00
|
|
|
if ($enableChangePasswordAfterNextLogin && !empty($errorInPassword)) {
|
2012-07-04 19:01:31 -04:00
|
|
|
if (!defined('NO_DISPLAY_USERNAME')) {
|
|
|
|
|
define('NO_DISPLAY_USERNAME', 1);
|
|
|
|
|
}
|
2018-10-26 16:14:37 -04:00
|
|
|
//We will to get the message for the login
|
2018-12-11 07:48:44 -04:00
|
|
|
$messPassword = $policySection = $userProperty->getMessageValidatePassword($policiesInPassword, false);
|
2018-10-26 16:14:37 -04:00
|
|
|
$changePassword = '<span style="font-weight:normal;">';
|
|
|
|
|
if (array_search('ID_PPP_CHANGE_PASSWORD_AFTER_NEXT_LOGIN', $errorInPassword)) {
|
|
|
|
|
$changePassword .= G::LoadTranslation('ID_PPP_CHANGE_PASSWORD_AFTER_NEXT_LOGIN') . '<br/><br/>';
|
2012-07-04 19:01:31 -04:00
|
|
|
}
|
2018-10-26 16:14:37 -04:00
|
|
|
|
2018-12-11 07:48:44 -04:00
|
|
|
$messPassword['DESCRIPTION'] = $changePassword . $policySection['DESCRIPTION'] . '</span>';
|
2012-07-04 19:01:31 -04:00
|
|
|
$G_PUBLISH = new Publisher;
|
2015-09-25 19:55:26 -04:00
|
|
|
$version = explode('.', trim(file_get_contents(PATH_GULLIVER . 'VERSION')));
|
|
|
|
|
$version = isset($version[0]) ? intval($version[0]) : 0;
|
2019-04-15 14:02:16 -04:00
|
|
|
|
2015-09-25 19:55:26 -04:00
|
|
|
if ($version >= 3) {
|
2019-04-15 14:02:16 -04:00
|
|
|
$values = [
|
|
|
|
|
"usrUsername" => $usr,
|
|
|
|
|
"usrPassword" => $pwd,
|
|
|
|
|
"userEnvironment" => config("system.workspace"),
|
|
|
|
|
"browserTimeZoneOffset" => $_POST['form']['BROWSER_TIME_ZONE_OFFSET']
|
|
|
|
|
];
|
|
|
|
|
$messPassword['__USR_PASSWORD_CHANGE__'] = G::generateUniqueID();
|
|
|
|
|
Cache::put($messPassword['__USR_PASSWORD_CHANGE__'], $values, 2);
|
|
|
|
|
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/changePasswordpm3', '', $messPassword, 'sysLoginVerify');
|
|
|
|
|
G::RenderPage('publish');
|
|
|
|
|
session_destroy();
|
2018-10-26 16:14:37 -04:00
|
|
|
} else {
|
|
|
|
|
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/changePassword', '', $messPassword, 'changePassword');
|
2019-04-15 14:02:16 -04:00
|
|
|
G::RenderPage('publish');
|
2015-05-07 17:13:45 -04:00
|
|
|
}
|
2012-07-04 19:01:31 -04:00
|
|
|
die;
|
2012-04-05 12:52:33 -04:00
|
|
|
}
|
|
|
|
|
|
2017-10-10 12:33:25 -04:00
|
|
|
$configS = System::getSystemConfiguration('', '', config("system.workspace"));
|
2016-03-15 11:54:22 -04:00
|
|
|
$activeSession = isset($configS['session_block']) ? !(int)$configS['session_block']:true;
|
2016-03-08 18:37:38 -04:00
|
|
|
if ($activeSession){
|
2021-11-26 15:58:35 +00:00
|
|
|
setcookie('PM-TabPrimary', 101010010, $cookieOptions);
|
2016-03-08 18:37:38 -04:00
|
|
|
}
|
|
|
|
|
|
2019-07-05 16:00:43 -04:00
|
|
|
// Update the User's last login date
|
|
|
|
|
updateUserLastLogin($aLog);
|
|
|
|
|
|
2017-08-01 12:16:06 -04:00
|
|
|
$oPluginRegistry = PluginRegistry::loadSingleton();
|
2014-07-23 12:12:50 -04:00
|
|
|
if ($oPluginRegistry->existsTrigger ( PM_AFTER_LOGIN )) {
|
|
|
|
|
$oPluginRegistry->executeTriggers ( PM_AFTER_LOGIN , $_SESSION['USER_LOGGED'] );
|
2014-07-23 09:20:31 -04:00
|
|
|
}
|
2014-07-23 12:12:50 -04:00
|
|
|
|
2017-06-19 16:21:40 -04:00
|
|
|
G::header('Location: ' . $sLocation);
|
2012-07-04 19:01:31 -04:00
|
|
|
die;
|
|
|
|
|
} catch ( Exception $e ) {
|
|
|
|
|
$aMessage['MESSAGE'] = $e->getMessage();
|
|
|
|
|
$G_PUBLISH = new Publisher;
|
|
|
|
|
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage );
|
|
|
|
|
G::RenderPage( 'publish' );
|
|
|
|
|
die;
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|