forked from YetiForceCompany/YetiForceCRM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
token.php
44 lines (42 loc) · 1.31 KB
/
token.php
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
/**
* Token file.
*
* @package Token
*
* @copyright YetiForce S.A.
* @license YetiForce Public License 6.5 (licenses/LicenseEN.txt or yetiforce.com)
* @author Mariusz Krzaczkowski <[email protected]>
*/
chdir(__DIR__);
require __DIR__ . '/include/main/WebUI.php';
require __DIR__ . '/include/RequirementsValidation.php';
\App\Controller\Headers::getInstance()->send();
\App\Process::$startTime = microtime(true);
\App\Process::$requestMode = 'Token';
if (!\App\Config::main('application_unique_key', false)) {
header('location: install/Install.php');
} else {
try {
$request = \App\Request::init();
if ($request->isEmpty('token')) {
throw new \App\Exceptions\AppException('ERR_NO_TOKEN', 405);
}
$token = $request->getByType('token', \App\Purifier::ALNUM);
$tokenData = \App\Utils\Tokens::get($token);
if (empty($tokenData)) {
throw new \App\Exceptions\Security('ERR_TOKEN_DOES_NOT_EXIST', 405);
}
$result = \App\Utils\Tokens::execute($token, $tokenData);
if (isset($result['redirect'])) {
header("location: {$result['redirect']}");
}
} catch (\Throwable $th) {
$message = $th->getMessage();
if ($th instanceof \App\Exceptions\AppException) {
$message = $th->getDisplayMessage();
}
echo $message;
\App\Log::info($th->getMessage() . PHP_EOL . $th->__toString());
}
}