* Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ use Core\Helpers\Captcha; use Core\Helpers\SystemFunctions; use Core\SystemConfig; use Core\Models\{User, UserMeta}; use Core\CoreException; require_once __DIR__ . '/inc/bootstrap.php'; // Определяем тип авторизации $authType = isset($_REQUEST['authType']) && !empty($_REQUEST['authType']) ? $_REQUEST['authType'] : 'default'; /** * array(7) { ["id"]=> string(7) "1831337" ["first_name"]=> string(18) "Александр" ["last_name"]=> string(16) "Менщиков" ["username"]=> string(5) "n0str" ["photo_url"]=> string(36) "https://t.me/i/userpic/100/n0str.jpg" ["auth_date"]=> string(10) "1518168109" ["hash"]=> string(64) "abba<..>1345" } */ switch ($authType) { case 'telegram': $data = [ 'id' => $_REQUEST['id'], 'first_name' => $_REQUEST['first_name'], 'last_name' => $_REQUEST['last_name'], 'username' => $_REQUEST['username'], 'photo_url' => $_REQUEST['photo_url'], 'auth_date' => $_REQUEST['auth_date'], 'hash' => $_REQUEST['hash'], ]; $isCorrectTelegramAuth = SystemFunctions::checkTelegramAuthorization($data); if ($isCorrectTelegramAuth) { $res = UserMeta::getListByParams(['name' => 'telegramId', 'value' => $data['id']]); if (!empty($res)) { $userId = array_shift($res)['user_id']; User::authorize($userId); header('Location: index.php'); die(); } } $auth = false; $err_mess = true; break; case 'default': $captchaCorrect = true; if (USE_CAPTCHA) { $captchaCorrect = isset($_REQUEST['captchaCode']) && Captcha::isValidCaptcha($_REQUEST['captchaCode']); } if (User::isAuthorized()) { $auth = true; } else { $auth = false; if ($captchaCorrect && !empty($_REQUEST['login'] && !empty($_REQUEST['pass']))) { if (User::securityAuthorize( $_REQUEST['login'], $_REQUEST['pass'], isset($_REQUEST['remember']) && $_REQUEST['remember'] === 'on' )) { $auth = true; } } } if ($auth === false && isset($_REQUEST['login']) && $_REQUEST['login'] !== '') { $err_mess = true; } else { $err_mess = false; } break; } if ($auth === true) { global $USER; if (isset($_REQUEST['loginAs']) && !empty($_REQUEST['loginAs']) && $USER->isAdmin()) { try { User::logout(); User::authorize($_REQUEST['loginAs']); die(); } catch (CoreException $e) { die('Авторизация не удалась'); } } header('Location: index.php'); } else { ?>
Войдите в свой аккаунт
Вы можете использовать для авторизации один из вариантов ниже