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".

  • so... how did it go? – No Sssweat Aug 5 '16 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 Aug 8 '16 at 21:53
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

  • @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 Jan 9 '18 at 22:32
  • hm, that sounds like what I was guessing also, so merci! – Pierre.Vriens Jan 9 '18 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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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