File size: 1,155 Bytes
07c3cdd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?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');
    }

    $_SESSION = [];
    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);