Documentation

OnBeforeUserLogin

bool
handler function(
 array &arParams
);
The event 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 event can be used to terminate verification process and to re-define specific fields.

Parameters

ParameterDescription
arParams Array of fields to verify login and password:
  • 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 set to "Y", the user authorization is to be saved in cookies.
  • 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.

Returned value

To undo user authorization and terminate the execution for the method CUser::SimpleRegister, throw an exception in the handler function via the method $APPLICATION->ThrowException() and return false.

See Also

Example of handler function:

<?
// file /bitrix/php_interface/init.php
// register the handler
AddEventHandler("main", "OnBeforeUserLogin", Array("MyClass", "OnBeforeUserLoginHandler"));
class MyClass { // create the event handler "OnBeforeUserLogin" function OnBeforeUserLoginHandler(&$arFields) { // execute any linked actions if(strtolower($arFields["LOGIN"])=="guest") { global $APPLICATION; $APPLICATION->throwException("User with the Guest login cannot be authorized."); return false; } } } ?>


© «Bitrix24», 2001-2022
Up