To allow the user to login with username or e-mail, both need to be exclusive / unique per user.
Otherwise you can never be sure of what is the user / person that is being authenticated.
In an extreme example: if both use the same password and login with the e-mail, which user would you load?
The objective for this logic is to be able to the users to login using username or email address, which is being stored in users database.
sample db structure.
username email address reason
testuser1 test@email.com (they are a couple that would share the same email)
testuser2 test@email.com
1.lets say a user login with test@email.com
2. get the current list in users table with has username of test@email.com
the result would contain 2 records.
3.then i would try to login the first record testuser1
if login <> true then
loop to the next record
problem: if i use the login functionality of users espace, during my initial login which is false
it would go to the exception page, what i wanted is, if the first login fails, it would loop as to how many records contains on the list using the test@email until it hit the correct password.
this feature or logic merely giving the users a flexibility to login both username and email.
Sample Implementation:

Thanks,
JunJun