Bitrix Site Manager

OnBeforeUserLoginByHash event

bool
event_handler(
 array &arParams
)

The OnBeforeUserLoginByHash event fires in the method CUser::LoginByHash() before the verification of login arParams['LOGIN'] and a password hash arParams['HASH'], before the authorization attempt.

Parameters

ParameterDescription
arParams Array of fields used for user login and password verification, the following keys available:
  • LOGIN - user login;
  • HASH - special hash calculated on password string. This value is usually stored in a user cookie.

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::LoginByHash 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", 
                "OnBeforeUserLoginByHash", 
                Array("MyClass", 
                      "OnBeforeUserLoginByHashHandler"));

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