Repeating "login successful message"

Created on 25 February 2013, over 11 years ago
Updated 9 February 2023, over 1 year ago

We are using a custom external login module to authenticate users on a new system. Basically converting a current Drupal 7 website using LoginToboggan already in use to a new version that uses all the same code with the exception of using a 3rd party user database. Everything is working fine but the "login successful message" was displaying 3 times. I managed to narrow it down to the LoginToboggan in the logintoboggan_user_login() function where it sets the message. The $repeat parameter is not set. So I'm guessing the user_login function is getting triggered several times while logging in the user with the external database and each time the function is triggered, logintoboggan_user_login sets the message again.

I tested this out and when I set $repeat to FALSE in the LoginToboggan module, the "login successful message" does not repeat anymore.

Before code

/**
 * Implement hook_user_login().
 */
function logintoboggan_user_login(&$edit, $account) {
  if (variable_get('logintoboggan_login_successful_message', 0)) {
    drupal_set_message(theme('lt_login_successful_message', array('account' => $account)));
  }
}

After code:

/**
 * Implement hook_user_login().
 */
function logintoboggan_user_login(&$edit, $account) {
  if (variable_get('logintoboggan_login_successful_message', 0)) {
    drupal_set_message(theme('lt_login_successful_message', array('account' => $account)), 'status', FALSE);
  }
}

I think this drupal_set_message() should be tweaked to set the $repeat to FALSE so the login message never repeats no matter the source.

πŸ“Œ Task
Status

RTBC

Version

1.3

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States mcannon Philadelphia, PA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States BBC Madison, WI

    10 years later, this patch applies cleanly and seems to work well, so marking RTBC. I'm running LoginToboggan and hybridauth together and found that I had a couple of users running into this. The login successful message appeared on every page. One user just had a regular login and has had this issue come and go intermittently over the last couple years, but this time around it was also affecting anyone used hybridauth to login via a Google Account.

    Thanks for the patch!

Production build 0.69.0 2024