-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathReadUserInfo.php
More file actions
44 lines (32 loc) · 794 Bytes
/
Copy pathReadUserInfo.php
File metadata and controls
44 lines (32 loc) · 794 Bytes
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
<?php
/**
* Created by PhpStorm.
* User: dronca
* Date: 11/18/18
* Time: 8:13 PM
*/
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: access");
header("Access-Control-Allow-Methods: GET");
header("Access-Control-Allow-Credentials: true");
header('Content-Type: application/json');
include_once 'lib/User.php';
include_once 'lib/DBHelper.php';
$dbh = new DBHelper();
$uToken = $_GET["userToken"];
error_log("Read user for token: ".$uToken);
$user = User::fromToken($uToken);
error_log($user->toString());
$ret = array();
if($user == null)
{
array_push($ret, "Invalid user token: ".$uToken);
}
else
{
array_push($ret, $user->toArray());
}
// set response code - 200 OK
http_response_code(200);
// make it json format
echo json_encode($ret);