@classmethod
def find(cls, email=None, password=None, edm_login_fallback=True):
    if (email is None):
        return None
    email_candidates = [email, ('%s@localhost' % (email,))]
    for email_candidate in email_candidates:
        user = cls.query.filter((User.email == email_candidate)).first()
        if (password is None):
            if (user is not None):
                return user
        else:
            if (user is not None):
                if (user.password == password):
                    return user
            if edm_login_fallback:
                if current_app.edm.check_user_login(email_candidate, password):
                    log.info(('User authenticated via EDM: %r' % (email_candidate,)))
                    if (user is not None):
                        if (user.password != password):
                            log.warning(("Updating user's local password: %r" % (user,)))
                            user = user.set_password(password)
                        return user
                    else:
                        log.critical('The user authenticated via EDM but has no local user record')
                        cls.edm_sync_all()
                        user = cls.find(email=email, edm_login_fallback=False)
                        return user
    return None
@classmethod
def find(cls, email=None, password=None, edm_login_fallback=True):
    if (email is None):
        return None
    email_candidates = [email, ('%s@localhost' % (email,))]
    for email_candidate in email_candidates:
        user = cls.query.filter((User.email == email_candidate)).first()
        if (password is None):
            if (user is not None):
                return user
        else:
            if (user is not None):
                if (user.password == password):
                    return user
            if edm_login_fallback:
                if current_app.edm.check_user_login(email_candidate, password):
                    log.info(('User authenticated via EDM: %r' % (email_candidate,)))
                    if (user is not None):
                        if (user.password != password):
                            log.warning(("Updating user's local password: %r" % (user,)))
                            user = user.set_password(password)
                        return user
                    else:
                        log.critical('The user authenticated via EDM but has no local user record')
                        cls.edm_sync_all()
                        user = cls.find(email=email, edm_login_fallback=False)
                        return user
    return None