python – Checking user credentials before logging in

I am trying to overwrite the login class, using the email instead of the username.
But this piece of code, which verifies if the user exists, seems creepy?
It is not?

def clean (self):
email = self.cleaned_data.get (& # 39; email & # 39;)
password = self.cleaned_data.get (& # 39; password & # 39;)

If it is not an email or a password:
raise self.get_invalid_login_error ()

user = User.objects.filter (email = email) .first ()

if the user is None:
raise self.get_invalid_login_error ()

self.user_cache = authenticate (self.request, username = user.username, password = password)

if self.user_cache is None:
raise self.get_invalid_login_error ()
plus:
self.confirm_login_allowed (self.user_cache)

returns self.cleaned_data