Files
vinoteca/local/components/jinove/auth.login/class.php
T

45 lines
1.7 KiB
PHP

<?php
declare(strict_types=1);
use Bitrix\Main\Application;
use Bitrix\Main\Engine\CurrentUser;
use Bitrix\Main\Localization\Loc;
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
die();
}
Loc::loadMessages(__FILE__);
class JinoveAuthLoginComponent extends CBitrixComponent
{
public function executeComponent(): array
{
$request = Application::getInstance()->getContext()->getRequest();
$embed = ($this->arParams["EMBED"] ?? "") === "Y";
$back = $embed ? (string)$GLOBALS["APPLICATION"]->GetCurPageParam("", array(), false) : (string)$request->getQuery("back");
$safeBack = \Jinove\Vinoteca\Redirect::safe($back);
if (!$embed) {
if ((int)CurrentUser::get()->getId() > 0) {
LocalRedirect($safeBack !== "" ? $safeBack : SITE_DIR);
}
$GLOBALS["APPLICATION"]->SetTitle(Loc::getMessage("VINO_AUTH_PAGE_TITLE"));
$GLOBALS["APPLICATION"]->SetPageProperty("description", Loc::getMessage("VINO_AUTH_PAGE_DESCRIPTION"));
$GLOBALS["APPLICATION"]->SetPageProperty("vino_alternates", "N");
$GLOBALS["APPLICATION"]->SetPageProperty("vino_schema", "N");
$GLOBALS["APPLICATION"]->SetPageProperty("robots", "noindex, nofollow");
}
$this->arResult = [
"EMBED" => $embed,
"TITLE" => (string)($this->arParams["TITLE"] ?? ""),
"LEAD" => (string)($this->arParams["LEAD"] ?? ""),
"BACK" => $safeBack,
"REGISTER_URL" => SITE_DIR . "register/" . ($safeBack !== "" ? "?back=" . rawurlencode($safeBack) : ""),
"FORGOT_URL" => SITE_DIR . "forgot-password/",
];
$this->includeComponentTemplate();
return $this->arResult;
}
}