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
Parameter | Description |
---|---|
arParams | Array of fields for login and password verification. The following keys are 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.
It allows, for example, to update RESULT_MESSAGE, which results to the updated message, returned by the function CUser::Login.
See Also
- "OnBeforeUserLogin" event
- CUser::Login
- Events
- External Authorization
Example of handler function:
<? AddEventHandler("main", "OnAfterUserLogin", Array("MyClass", "OnAfterUserLoginHandler"));
class MyClass { // cre ate event handler "OnAfterUserLogin" public static 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-2023