def METHOD_NAME(request: HttpRequest, require_password: bool, registration: bool) -> bool:
    """Check if user exists, check if the provided passwords match, and if the device id matches."""
    # even if the password won't be checked we want the key to be present.
    try:
        rp = request.POST
    except UnreadablePostError:
        return abort(500)
    if "patient_id" not in rp or "password" not in rp or "device_id" not in rp:
        log("missing parameters entirely.")
        log("patient_id:", "patient_id" in rp)
        log("password:", "password" in rp)
        log("device_id:", "device_id" in rp)
        return False
    log("all parameters present...")
    # FIXME: Device Testing. need to check the app expectations on response codes
    #  this used to throw a 400 if the there was no patient_id field in the post request,
    #  and 404 when there was no such user, when it was get_session_participant.
    # This isn't True? the old code included the test for presence of keys, and returned False,
    #  triggering the os-specific failure codes.
    try:
        session_participant: Participant = \
            Participant.objects.get(patient_id=request.POST['patient_id'])
    except Participant.DoesNotExist:
        log("invalid patient_id")
        return False
    except UnreadablePostError:
        return abort(500)
    if session_participant.is_dead:
        log("locked participant")
        return False
    # check participants and studies for easy enrollment
    if registration:
        if session_participant.easy_enrollment or session_participant.study.easy_enrollment:
            require_password = False
    try:
        if require_password:
            if not session_participant.validate_password(request.POST['password']):
                log("incorrect password")
                return False
            log("password passes validation")
        else:
            log("password validation skipped")
    except UnreadablePostError:
        return abort(500)
    tracking_updates = {}
    if "version_code" in request.POST:
        tracking_updates['last_version_code'] = request.POST["version_code"][:32]
    if "version_name" in request.POST:
        tracking_updates['last_version_name'] = request.POST["version_name"][:32]
    if "os_version" in request.POST:
        tracking_updates['last_os_version'] = request.POST["os_version"][:32]
    if tracking_updates:
        session_participant.update_only(**tracking_updates)
    # attach session partipant to request object, defining the ParticipantRequest class.
    request.session_participant = session_participant
    return True