Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-20941

Store hashed username into user->email field for deleted users

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.8.10, 1.9.6
    • Fix Version/s: 1.8.11, 1.9.7
    • Component/s: Administration, Libraries
    • Labels:
      None
    • Affected Branches:
      MOODLE_18_STABLE, MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_18_STABLE, MOODLE_19_STABLE

      Description

      Right now, when one user is deleted from Moodle server this happens (delete_user() function):

      • user->username is set to user->email + random string
      • user->email is cleaned (empty string)

      So we lost any original username information forever.

      And that is good in the sense that leaves the username free to be reused by other user later. But it's definitively wrong when we try to import (csv, restore...) users and perform various checks to see if one user already existed. And that can lead to "revived" users that shouldn't be there.

      So, in order to keep the deleted username free to be reused, we are going to start storing the md5 hash of the username into the email field, so utilities creating users will be able to compare that hash in order to detect if the user already existed or no.

      Obviously that md5 only will be there for users deleted in the future and old deletions will continue having empty strings forever, so import utilities only will rely on that hash if not empty (this is one important point).

      So, starting now, we are going to do this on user deletion:

      • user->username is set to user->email + random string (no change here)
      • user->email is set to md5(user->username)

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Votes:
                  0 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    25/Nov/09