When a user logs in using email address instead of username, then change his email, he is no longer logged in but also can't log out. As searches in LDAP were based on the same credential than supplied when logging in, theses searches no longer returned anything if user email has changed.
With this fix, user is searched using email only first time just after at log-in, then username is recorded as credential for the rest of the session (as if the user has logged in using username), which allows further email change without issue.
When a user logs in using email address instead of username, then change his email, he is no longer logged in but also can't log out. As searches in LDAP were based on the same credential than supplied when logging in, theses searches no longer returned anything if user email has changed.
With this fix, user is searched using email only first time just after at log-in, then username is recorded as credential for the rest of the session (as if the user has logged in using username), which allows further email change without issue.