Bitrix Site Manager

OnBeforeUserLogin event

bool
event_handler(
 array &arParams
);

The OnBeforeUserLogin event is fired in the method CUser::Login before a user authorization attempt (before the login arParams['LOGIN'] and password arParams['PASSWORD'] are both verified). This can be used to cancel the process of fields checking or redefining.

Parameters

ParameterDescription
arParams Array of fields used for user login and password verification, the following keys available:
  • LOGIN - user login;
  • PASSWORD - user password. If the value of PASSWORD_ORIGINAL is "Y", this parameter contains the original password. Otherwise, this parameter contains the MD5 hash value of the original password.
  • REMEMBER - if "Y", the user authorization information is to be stored in cookie.
  • PASSWORD_ORIGINAL - if "Y", the value of the PASSWORD field contains the original password typed by a user (not converted to MD5). If "N", the value of the PASSWORD field is converted to MD5.

Note
All parameters passed to this handler function are references to original variables. Therefore, all changes to parameters made within the handler affect values of the original variables.

Return Values

To cancel the user authorization and terminate the CUser::Login method, raise an exception from within the handler using the method $APPLICATION->ThrowException() and return false.

See Also

Example



<?
// file /bitrix/php_interface/init.php
// register handler
AddEventHandler("main", 
                "OnBeforeUserLogin", 
                Array("MyClass", 
                      "OnBeforeUserLoginHandler"));

class MyClass
{
    // create handler "OnBeforeUserLogin"
    function OnBeforeUserLoginHandler(&$arFields)
    {
        // perform any actions here 
        if (strtolower($arFields["LOGIN"]) == "guest")
        {
            global $APPLICATION;
            $APPLICATION->throwException("User named Guest cannot be authorized.");
            return false;
        }
    }
}
?>