Files
luos/workflow/engine/methods/services/webentry/anonymousLogin.php
davidcallizaya ec6995972e HOR-3996
Since the web entry is assigned to guest, it was not able to load the user information through
the PMfunctions because it is validated to not return guest information. Now it will load directly
from Users table.
2017-10-20 12:02:13 -04:00

44 lines
1.1 KiB
PHP

<?php
/**
* This service is to start PM with the anonymous user.
*/
/* @var $RBAC RBAC */
global $RBAC;
G::LoadClass('pmFunctions');
try {
if (empty($_REQUEST['we_uid'])) {
throw new Exception('Missing required field "we_uid"');
}
$weUid = $_REQUEST['we_uid'];
$webEntry = WebEntryPeer::retrieveByPK($weUid);
if (empty($webEntry)) {
throw new Exception('Undefined WebEntry');
}
$userUid = $webEntry->getUsrUid();
$userInfo = UsersPeer::retrieveByPK($userUid);
if (empty($userInfo)) {
throw new Exception('WebEntry User not found');
}
initUserSession($userUid, $userInfo->getUsrUsername());
$result = [
'user_logged' => $userUid,
'userName' => $userInfo->getUsrUsername(),
'firstName' => $userInfo->getUsrFirstName(),
'lastName' => $userInfo->getUsrLastName(),
'mail' => $userInfo->getUsrEmail(),
'image' => '../users/users_ViewPhoto?t='.microtime(true),
];
} catch (Exception $e) {
$result = [
'error' => $e->getMessage(),
];
http_response_code(500);
}
echo G::json_encode($result);