def METHOD_NAME(self, attrs):
    username = attrs.get("username")
    email = attrs.get("email")
    password = attrs.get("password")
    user = None
    if "allauth" in settings.INSTALLED_APPS:
        from allauth.account import app_settings
        # Authentication through email
        if (
            app_settings.AUTHENTICATION_METHOD
            == app_settings.AuthenticationMethod.EMAIL
        ):
            user = self._validate_email(email, password)
        # Authentication through username
        elif (
            app_settings.AUTHENTICATION_METHOD
            == app_settings.AuthenticationMethod.USERNAME
        ):
            user = self._validate_username(username, password)
        # Authentication through either username or email
        else:
            user = self._validate_username_email(username, email, password)
    else:
        # Authentication without using allauth
        if email:
            try:
                username = User.objects.get(email__iexact=email).get_username()
            except User.DoesNotExist:
                pass
        if username:
            user = self._validate_username_email(username, "", password)
    # Did we get back an active user?
    if user:
        if not user.is_active:
            msg = _("User account is disabled.")
            raise AuthenticationFailed(msg)
    else:
        msg = _("Unable to log in with provided credentials.")
        raise AuthenticationFailed(msg)
    attrs["user"] = user
    return attrs