本文整理汇总了PHP中CUser::Authorize方法的典型用法代码示例。如果您正苦于以下问题:PHP CUser::Authorize方法的具体用法?PHP CUser::Authorize怎么用?PHP CUser::Authorize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUser
的用法示例。
在下文中一共展示了CUser::Authorize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Add
public function Add()
{
\ChromePhp::log("Subscr CRUD Add");
if ($subscriber = $this->getSubscriber()) {
$this->user = \CUser::GetByID($subscriber)->Fetch();
\CUser::Authorize($this->user["ID"]);
if ($subscribe = \CSubscription::GetList(False, array("ACTIVE" => "Y", "USER_ID" => $this->user["ID"]))->Fetch()) {
return $subscribe["ID"];
} else {
try {
return $this->addSubscribe();
} catch (SubscribeException $e) {
prentExpection($e->getMessage());
}
}
} else {
throw new SubscribeUserException("No user for add to subscribers" . ". Line: " . __LINE__);
}
}
示例2: trim
}
if (trim($_POST["WORK_PHONE"]) != '') {
$arFields["WORK_PHONE"] = trim($_POST["WORK_PHONE"]);
}
if (is_array($_FILES["PERSONAL_PHOTO"])) {
$arFields["PERSONAL_PHOTO"] = $_FILES["PERSONAL_PHOTO"];
}
$obUser = new CUser();
$obUser->Update($arResult["USER"]["ID"], $arFields);
$strError = $obUser->LAST_ERROR;
if ($strError == '') {
$db_events = GetModuleEvents("main", "OnUserInitialize", true);
foreach ($db_events as $arEvent) {
ExecuteModuleEventEx($arEvent, array($arResult["USER"]["ID"], $arFields));
}
$obUser->Authorize($arResult["USER"]["ID"], $_POST["USER_REMEMBER"] == "Y");
LocalRedirect(SITE_DIR);
} else {
$arResult["MESSAGE_TEXT"] .= $strError;
$arResult["MESSAGE_CODE"][] = "E10";
$arResult["SHOW_FORM"] = true;
}
}
}
if (empty($arResult["MESSAGE_CODE"])) {
$arResult["SHOW_FORM"] = true;
}
} else {
$arResult["MESSAGE_TEXT"] .= GetMessage("CC_MAIN_REG_INIT_MESSAGE_NO_USER");
$arResult["MESSAGE_CODE"][] = "E01";
}
示例3: CUser
//Пользователь с логином не найден!';
if ($userFromFB_ID = User::findFromFB($arFileds["id"])) {
// ищем по ID Facebook
$ID = $userFromFB_ID;
} else {
//тогда создаем нового пользователя
$user = new CUser();
$password = randString(7);
$arFields = array("NAME" => $arFileds["first_name"], "LAST_NAME" => $arFileds["last_name"], "EMAIL" => $arFileds["email"], "LOGIN" => $arFileds["email"], "PERSONAL_BIRTHDAY" => str_replace("/", ".", $arFileds["birthday"]), "LID" => "ru", "ACTIVE" => "Y", "PASSWORD" => $password, "CONFIRM_PASSWORD" => $password, "PERSONAL_PHOTO" => CFile::MakeFileArray("http://graph.facebook.com/" . $arFileds["id"] . "/picture?type=large"));
$ID = $user->Add($arFields);
}
}
// Тут пользователь должен быть полюбому
// Авторизуем его
$userRes = new CUser();
$userRes->Authorize($ID);
}
//Получаем друзей пользователя Фэйсбука
$fUrl = "https://graph.facebook.com/me/friends?access_token={$fb_token}";
$fResponse = file_get_contents($fUrl);
$FriendsData = json_decode($fResponse);
$FriendsDataSerialized = serialize($FriendsData);
$ob = CIBlockElement::GetList(array("SORT" => "ASC"), array("PROPERTY_USER" => $USER::GetId(), "IBLOCK_ID" => IB_USER_PROPS), FALSE, FALSE, array("ID", "PROPERTY_USER", "PROPERTY_LINK_NEWS", "PROPERTY_LINK_EVENT", "PROPERTY_LINK_STOK"))->Fetch();
if ($ob) {
CIBlockElement::SetPropertyValuesEx(intval($ob["ID"]), IB_USER_PROPS, array("TOKEN_FACEBOOK" => $fb_token, "FRIENDS_FACEBOOK" => $FriendsDataSerialized, "ID_FACEBOOK" => $arFileds["id"]));
if ($_GET['r']) {
$path = base64_decode($_GET['r']);
header('Location: ' . $path);
exit;
}
}
示例4: TempUser
public static function TempUser($TmpUser = false, $create = true, $ID = false)
{
global $USER;
if ($create && $TmpUser === false && (!$USER || !is_object($USER))) {
$USER = new CUser();
if ($ID && intVal($ID) > 0) {
$USER->Authorize(intVal($ID));
}
return $USER;
} elseif (!$create && $USER && is_object($USER)) {
unset($USER);
return false;
}
return false;
}
示例5: trim
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
$email = trim($_POST["email"]);
$reg = intval($_POST["reg"]);
$password = trim($_POST["password"]);
if ($email == "" || $password == "") {
die(json_encode(array("status" => "errors", "message" => "Пустой логин или пароль", "input" => array("email", "password"))));
}
global $USER;
$user = new CUser();
$arAuthResult = $user->Login($email, $password, "Y");
if ($arAuthResult['TYPE'] != "ERROR") {
die(json_encode(array("status" => "ok")));
} elseif ($reg == 1) {
if (CUser::GetByLogin($email)->Fetch() == NULL) {
$arFields = array("EMAIL" => $email, "LOGIN" => $email, "ACTIVE" => "Y", "PASSWORD" => $password, "CONFIRM_PASSWORD" => $password);
$ID = $user->Add($arFields);
if (intval($ID) > 0) {
if ($user->Authorize($ID)) {
die(json_encode(array("status" => "ok")));
} else {
die(json_encode(array("status" => "ok", "message" => "Не получилось авторизировать")));
}
} else {
die(json_encode(array("status" => "errors", "message" => $user->LAST_ERROR)));
}
} else {
die(json_encode(array("status" => "errors", "message" => "Логин уже занят")));
}
} else {
die(json_encode(array("status" => "errors", "message" => "Неверный пароль", "input" => array("email", "password"))));
}