event_handler( array &arParams );
The OnAfterUserLogin event is called from the method CUser::Login after a user authorization attempt (after the login arParams['LOGIN'] and password arParams['PASSWORD'] are both verified).
Parameter | Description |
---|---|
arParams | Array of fields used for user login and password verification, the following keys available:
|
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.
<? AddEventHandler("main", "OnAfterUserLogin", Array("MyClass", "OnAfterUserLoginHandler")); class MyClass { // create the OnAfterUserLogin handler 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) { // lookup a user by login $rsUser = CUser::GetByLogin($fields['LOGIN']); // if found... if ($arUser = $rsUser->Fetch()) { // lock the user profile $user = new CUser; $user->Update($arUser["ID"],array("ACTIVE" => "N")); // assign message $fields['RESULT_MESSAGE'] = array("TYPE" => "ERROR", "MESSAGE" => "Your account is disabled."); } } } } } ?>
© 2001-2005 Bitrix | Bitrix Site Manager - Content Management & Portal Solutions |