Authorize
Description and parameters
bool CSubscription::Authorize( int ID, string CONFIRM_CODE = false );
Method authorizes visitor for editing a subscription. Successful authorization attribute is saved in PHP session($_SESSION["SESS_SUBSCR_AUTH"][$ID]).
In case of anonymous subscription, authorization is verified by subscription verification code. If subscription belongs to a registered user, access is granted only to the authorized user-subscription owner. Static method.
Parameters
Parameter | Description | Available from version |
---|---|---|
ID | Subscription ID. | |
CONFIRM_CODE | Password for access authorization, must match with subscription verification code, generated when adding or updating subscription address. In case this parameter is false, authorization is unconditional. |
Returned value
On successful subscription authorization, returns true, otherwise false.
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)); }
© «Bitrix24», 2001-2024