• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/authentication/shortcode.php
  • Класс: BitrixMainAuthenticationShortCode
  • Вызов: ShortCode::load
protected function load()
{
	$userId = $this->context->getUserId();
	$primaryKey = [
		"USER_ID" => $userId,
		"CODE_TYPE" => $this->type,
	];

	$code = UserAuthCodeTable::getById($primaryKey)->fetchObject();

	if(!$code)
	{
		//first time for the user, should create a record
		$code = UserAuthCodeTable::createObject();
		$code->setUserId($userId);
		$code->setCodeType($this->type);

		$result = $code->save();
		if(!$result->isSuccess())
		{
			return false;
		}
	}

	$this->code = $code;

	return true;
}