moodle-tool_mfa icon indicating copy to clipboard operation
moodle-tool_mfa copied to clipboard

Event `user_failed_mfa` never seems to trigger

Open pjohanneson opened this issue 11 months ago • 0 comments

I've written a little plugin to log Moodle user authentication successes and failures to a system log. I'm able to see authentication success and failures in the log file, using the built-in \core\event\user_loggedin and \core\event\user_login_failed events.

I discovered that this MFA plugin, which we're using, also provides events: \tool_mfa\event\user_passed_mfa and \tool_mfa\event\user_failed_mfa. I added listeners for those two events to my plugin:

$observers = array(
    //...
    array(
            'eventname' => '\tool_mfa\event\user_passed_mfa',
            'callback'  => '\local_mylogintracker\tracker::mfa_success',
    ), 
    array(
            'eventname' => '\tool_mfa\event\user_failed_mfa',
            'callback'  => '\local_mylogintracker\tracker::mfa_failure',
    ), 
);

I see events for the MFA success event, but no matter how many times I key in a bogus MFA code, I never seem to trigger the \tool_mfa\event\user_failed_mfa event.

Any advice?

pjohanneson avatar Jan 20 '25 19:01 pjohanneson