Documentation

OnAfterUserLogin

handler function(
 array &arParams
);

The event OnAfterUserLogin is called in the method CUser::Login after a user authorization attempt (after login arParams['LOGIN'] and password arParams['PASSWORD'] are both verified.

Parameters

ParameterDescription
arParams Array of fields for login and password verification. The following keys are available:
  • USER_ID - contains user ID on successful authorization
  • RESULT_MESSAGE - array with text, describing the user verification result. Subsequently used by the function ShowMessage to display message.
  • LOGIN - user login
  • PASSWORD - Password. If PASSWORD_ORIGINAL set to "Y", this parameter passed original password, otherwise the cache (md5) from the original password was passed.
  • REMEMBER - if set to "Y", user authorization will be said 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.
It allows, for example, to update RESULT_MESSAGE, which results to the updated message, returned by the function CUser::Login.

See Also

Example of handler function:

<?
AddEventHandler("main", "OnAfterUserLogin", Array("MyClass", "OnAfterUserLoginHandler"));
class MyClass { // cre ate event handler "OnAfterUserLogin" function OnAfterUserLoginHandler(&$fields) { // if the login failed... if($fields['USER_ID']<=0) { // increment the login failure counter $_SESSION["AUTHORIZE_FAILURE_COUNTER"]++; // if the number of unsuccessful login attempts exceeds 10 if ($_SESSION["AUTHORIZE_FAILURE_COUNTER"]>10) { // search user by login $rsUser = CUser::GetByLogin($fields['LOGIN']); // if the user is found if ($arUser = $rsUser->Fetch()) { // lock the user profile $user = new CUser; $user->Update($arUser["ID"],array("ACTIVE" => "N")); // specify the message $fields['RESULT_MESSAGE'] = array("TYPE" => "ERROR", "MESSAGE" => "You account is disabled."); } } } } } ?>


© «Bitrix24», 2001-2022
Up