def METHOD_NAME(
    request: HttpRequest, user: User, backend: Optional[str] = None
) -> bool:
    if not user.mfakey_set.exists():
        # Perform login
        auth.login(request, user, backend=backend)
        return True
    return False