[ "prefilters" => [new HttpMethod([HttpMethod::METHOD_POST]), new Csrf(), new FormGuard(FormGuard::TIMING_ELAPSED)], ], ]; } public function loginAction( string $email, string $password, string $remember = "", string $consent = "", string $back = "", string $lang = "en", string $website = "", int $elapsed = 0, string $altcha = "" ): ?array { $lang = Redirect::language($lang); if ($website !== "") { return ["ok" => true, "redirect" => Redirect::home($lang)]; } $session = Application::getInstance()->getSession(); if ((int)($session->get("vino_login_block") ?? 0) > time()) { $this->addError(new Error("Too many attempts", "too_often")); return null; } $email = mb_strtolower(trim($email)); if ($consent !== "1" || !check_email($email) || $password === "" || mb_strlen($password) > 200) { $this->addError(new Error("Invalid credentials", "invalid")); return null; } $user = UserTable::getRow([ "select" => ["LOGIN"], "filter" => ["=EMAIL" => $email, "=ACTIVE" => "Y"], ]); $logged = false; if ($user !== null) { global $USER; $logged = $USER->Login((string)$user["LOGIN"], $password, $remember === "1" ? "Y" : "N") === true; } if (!$logged) { $fails = (int)($session->get("vino_login_fails") ?? 0) + 1; if ($fails >= self::MAX_FAILS) { $session->set("vino_login_block", time() + self::BLOCK_SECONDS); $fails = 0; } $session->set("vino_login_fails", $fails); $this->addError(new Error("Invalid credentials", "invalid")); return null; } $session->remove("vino_login_fails"); $session->remove("vino_login_block"); return ["ok" => true, "redirect" => Redirect::back($back, $lang)]; } }