Exemple #1
0
def connect_icloud():
    username, password = request.form["username"], request.form["password"]
    findmyi = FindMyI(username, password)
    if findmyi.get_partition():
        icloud_user = iCloudUser.query.filter_by(username=username).first()
        if icloud_user is None:
            icloud_user = iCloudUser(session["user_id"], username, password)
        elif icloud_user.user_id == session["user_id"]:
            icloud_user.password = password
        else:
            return jsonify(success=0, error="This iCloud Account Aleady Accociated With Another Account")
        db.session.add(icloud_user)
        db.session.commit()
        update_account(icloud_user.id, username, password)
        return jsonify(success=1, session={})

    return jsonify(success=0, error="Incorrect Username and Password")
Exemple #2
0
def update_account(id, username, password):
    manager = FindMyI(username, password)
    if manager.get_partition():
        manager.update_devices()
        for device in manager.devices:
            device_obj = Device.query.filter_by(aid=device['aid']).first()
            if device_obj is None:
                device_obj = Device()
                device_obj.user_id = id
                device_obj.aid = device['aid']
                device_obj.name = device['name']
                device_obj.device_name = device['device_display_name']
                db.session.add(device_obj)
                db.session.commit()
            if 'located' in device:
                print device
                location = Location(device_obj.id, device['longitude'], device['latitude'],  device['accuracy'], datetime.datetime.fromtimestamp(device['timestamp']/1000.0))
                db.session.add(location)
        db.session.commit()