Bitrix Site Manager

OnAfterUserLoginByHash event

event_handler(
 array &arParams
);

The OnAfterUserLoginByHash event is called from the method CUser::LoginByHash() after the verification of login arParams['LOGIN'] and a password hash arParams['HASH'], after the authorization attempt.

The field arParams['USER_ID'] contains the ID of a successfully authorized user. The array arParams['RESULT_MESSAGE']. contains the error description.

Parameters

ParameterDescription
arParams Array of fields used for user login and password verification, the following keys available:
  • USER_ID - contains a valid user ID on successful authorization;
  • RESULT_MESSAGE - array containing the verification result description (can be passed to ShowMessage to display a message);
  • 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.

For example, this allows to modify the RESULT_MESSAGE, which will change message returned by the method CUser::Login.

See Also

Example



// file /bitrix/php_interface/init.php
// register handler
AddEventHandler("main", 
                "OnAfterUserLoginByHash", 
                Array("MyClass", 
                      "OnAfterUserLoginByHashHandler"));

class MyClass
{
    // create OnAfterUserLoginByHash handler
    function OnAfterUserLoginByHashHandler(&$arParams)
    {
        if ($arParams['USER_ID']<=0)
        {
            // redefine the error message.
            $arParams['RESULT_MESSAGE'] = 
                Array("MESSAGE" => "New error.", 
                      "TYPE" => "ERROR");
        }
    }
}
?>