Bitrix Site Manager

CSubcription::Authorize

CSubcription::Authorize(
    $ID, 
    $CONFIRM_CODE=false
);

The method Authorize is used to authorize a visitor before he can start modifying his subscription. Successful authorization is stored in the PHP session.

In case of anonymous subscription, authorization is checked by the subscription confirmation code. If the subscription belongs to a registered user, the access is only given to the authorized user who is the owner of this subscription.

Parameters

ParameterDescription
$ID The subscription ID.
$CONFIRM_CODE Access authorization password. Should be the same as the subscription confirmation code. If the parameter has the value false, authorization is always performed.

Return Values

Returns true on success, or false otherwise.

Example



//try to authorize subscription by CONFIRM_CODE or user password AUTH_PASS
if($ID > 0 && !CSubscription::IsAuthorized($ID))
{
    if($str_USER_ID > 0 && !empty($AUTH_PASS))
    {
        //trying to login user
        $usr = CUser::GetByID($str_USER_ID);
        if(($usr_arr = $usr->Fetch()))
        {
            $res = $USER->Login($usr_arr["LOGIN"], $AUTH_PASS);
            if($res["TYPE"] == "ERROR")
                $strWarning .= $res["MESSAGE"];
        }
    }
    CSubscription::Authorize($ID, (empty($AUTH_PASS)? $CONFIRM_CODE:$AUTH_PASS));
}