Files
luos/workflow/engine/methods/services/webentry/anonymousLogin.php

44 lines
1.1 KiB
PHP
Raw Normal View History

2017-06-02 13:07:52 -04:00
<?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"');
2017-06-02 13:07:52 -04:00
}
$weUid = $_REQUEST['we_uid'];
$webEntry = WebEntryPeer::retrieveByPK($weUid);
2017-06-02 13:07:52 -04:00
if (empty($webEntry)) {
throw new Exception('Undefined WebEntry');
2017-06-02 13:07:52 -04:00
}
$userUid = $webEntry->getUsrUid();
$userInfo = UsersPeer::retrieveByPK($userUid);
2017-06-02 13:07:52 -04:00
if (empty($userInfo)) {
throw new Exception('WebEntry User not found');
2017-06-02 13:07:52 -04:00
}
initUserSession($userUid, $userInfo->getUsrUsername());
2017-06-02 13:07:52 -04:00
$result = [
'user_logged' => $userUid,
'userName' => $userInfo->getUsrUsername(),
'firstName' => $userInfo->getUsrFirstName(),
'lastName' => $userInfo->getUsrLastName(),
'mail' => $userInfo->getUsrEmail(),
2017-06-02 13:07:52 -04:00
'image' => '../users/users_ViewPhoto?t='.microtime(true),
];
} catch (Exception $e) {
2017-06-02 13:07:52 -04:00
$result = [
'error' => $e->getMessage(),
];
http_response_code(500);
}
echo G::json_encode($result);