User hook for failed login issue

I’ve been trying to add a logic hook after login failed on Users, but I cannot get it to work. I get a blank page after the login failed. The only logic I’m adding to be executed is printing to the log file, but nothing gets added to the log. Has anybody deal with this issue or used this type of hook.

SuiteCRM 7.11.18

I’m adding this:

  1. /custom/modules/Users/logic_hooks.php

$hook_version = 1;
$hook_array = Array();
$hook_array[‘login_failed’] = Array();
$hook_array[‘login_failed’][] = Array(1, ‘login_failed’, ‘custom/modules/Users/User_Hooks.php’, ‘User_Hooks’, ‘login_failed’);

  1. custom/modules/Users/User_Hooks.php

if (!defined(‘sugarEntry’) || !sugarEntry) die(‘Not A Valid Entry Point’);

class User_Hooks{

function login_failed($bean, $event, $arguments){

   $GLOBALS['log']->fatal('Login failed for user ');

}
}

  1. Did the repair and rebuild
  2. If I try to login with the wrong password, I get a blank index page

Hey there,

Thank you for the detailed post, I was able to replicate it fairly easily!

So, I think the issue is that the “login_failed” logic hook action must not supply a bean parameter, as the CRM assumes a function without “$bean”.
See this code in “Include/utils/LogicHooks.php”


So, in the Logic Hook itself;

As your function: “function login_failed($bean, $event, $arguments){” code contains $bean, an error occurs.


Long story short, I think you just need to remove “$bean” from your function, like so:

image

and it should work!

Let me know if you have any issues!

1 Like

thank you @John
That was the isssue.

1 Like