3

I need to implement the functionality to notify the admin user via email whenever someone fails to login entering wrong password. Basically simple email format containing the username for failed account to login. Can someone give guidance or suggestion?

P.S: I checked the Rules module but it doesn't have required Rules event like "When user fails to login".

2
  • so... how did it go?
    – No Sssweat
    Commented Aug 5, 2016 at 9:43
  • @No Sssweat: Your suggestion was quick and easy implementation, however i needed exact requirement functionality, i.e. send email on first failed login, also capture username and time. Hence, i created custom module utilizing user_authenticate() - to check if login/pass match inside my custom form validation and simply triggered drupal_mail() when user_authenticate()=false.
    – Laziz
    Commented Aug 8, 2016 at 21:53

2 Answers 2

2

People mistype or use wrong alternate passwords all the time. Would be overkill to send e-mail on a first failed attempt.

For security reasons, Drupal blocks user account after 5 login failed attempts.

You can use Rules Block/Unblock User to send e-mail when user gets blocked. (failed 5 times)

This module adds rules events, as well as some default rules, for when a user account is blocked or unblocked.

enter image description here

2
  • @Pierre.Vriens can't remember, but either back in the day DA allowed drupal.org .png files to be imported OR I did a copy paste to an image editing program then saved to my hard drive and uploaded it.
    – No Sssweat
    Commented Jan 9, 2018 at 22:32
  • hm, that sounds like what I was guessing also, so merci! Commented Jan 9, 2018 at 22:59
1

You can send mail only those user to whom has an data against the user name provided on login time. You can send mail using hook_mail. So on user login time you have to validate the data.

  1. define a validation function using form alter().
  2. validate user authentication (how to validate)
  3. if fail fetch user data and call drupal_mail function more info.

I hope it will help you

2
  • Thanks! your guidance was helpful. I implemented custom validation function which uses !user_authenticate() and drupal_mail() with hook_mail()
    – Laziz
    Commented Aug 8, 2016 at 22:07
  • Welcome .....:)
    – bisw
    Commented Aug 10, 2016 at 5:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.