sign-in.php
См. документацию.
1 <?php
2 
3 /**
4  * @file
5  * @brief обработчик формы входа в систему
6  */
7 
8 isset($user) or require $_SERVER['DOCUMENT_ROOT'] . '/page/404.php';
9 
10 header("Content-type: application/json");
11 
12 if (empty($_POST['email']) || !filter_var(trim($_POST['email']), FILTER_VALIDATE_EMAIL)) {
13  exit(json_encode(['error' => 'email']));
14 }
15 
16 if (empty($_POST['password'])) {
17  exit(json_encode(['error' => 'password']));
18 }
19 
20 if (!Wrong\Auth\Hcaptcha::check() && (empty($_POST['h-captcha-response']) || !Wrong\Auth\Hcaptcha::get($_POST['h-captcha-response']))) {
21  exit(json_encode(['error' => 'hcaptcha']));
22 }
23 
25 
26 if (!$user || $user->md5password != md5(trim($_POST['password']))) {
28  exit(json_encode(['error' => 'auth']));
29 }
30 
31 if (!$user->act) {
32  exit(json_encode(['error' => 'unknown']));
33 }
34 
35 if ($user = new Wrong\Auth\User(Wrong\Auth\User::session($user->id))) {
36  if ($user->access()->page('/system')) {
37  Wrong\Task\Stackjs::add('location.href="/system";', 0, 'location');
38  } else {
39  Wrong\Task\Stackjs::add('location.reload();', 0, 'location');
40  }
41  exit(json_encode(['result' => 'ok']));
42 }
$_POST['groups']
Definition: add-action.php:16
if(empty($_POST['email'])||!filter_var(trim($_POST['email']), FILTER_VALIDATE_EMAIL)) if(empty($_POST['password'])) if(!Wrong\Auth\Hcaptcha::check() &&(empty($_POST['h-captcha-response'])||!Wrong\Auth\Hcaptcha::get($_POST['h-captcha-response']))) $user
Definition: sign-in.php:24
static match($email)
Definition: User.php:262
static add($code, $timeout=0, $key='')
Definition: Stackjs.php:25
setcookie('FROM_UID', $uid, [ 'expires'=> time()+31536000, 'path'=> '/', 'domain'=> $_SERVER['HTTP_HOST'], 'secure'=> Wrong\Start\Env::$e->IS_SECURE, 'httponly'=> false, 'samesite'=> Wrong\Start\Env::$e->IS_SECURE ? 'None' :'Lax']) or setcookie('FROM_UID' $_SERVER['HTTP_HOST']
Definition: from-user.php:36
if(($dbh=Connect::getInstance(true) ->dbh) && $dbh->query("SHOW TABLES") ->fetchAll() && $dbh->query("SELECT COUNT(*) FROM `users`") ->fetchColumn()) if(!empty($_POST)) exit
Definition: install.php:198