コード例 #1
0
def getUsersInBuilding():
    data = request.get_json(silent=True)
    buildingID = data['buildingID']
    token = data['token']
    if auth.checkToken(token):
        userList = f.getUsersInBuilding(db, buildingID)
        return jsonify(userList)  # returns a list of user ID's
    return '[S] Wrong token'
コード例 #2
0
def addBuildingToDB():
    data = request.get_json(silent=True)
    buildingID = data['buildingID']
    buildingName = data['buildingName']
    latitude = data['latitude']
    longitude = data['longitude']
    token = data['token']
    if auth.checkToken(token):
        print('Received new building info: ID: ' + str(buildingID) +
              ' name: ' + buildingName + ' latitude: ' + str(latitude) +
              ' longitude: ' + str(longitude))
        db.addBuilding(buildingID, buildingName, latitude, longitude)
        return '[S] Received building ID ' + str(
            buildingID) + ' : ' + buildingName
    return '[S] Wrong session token'
コード例 #3
0
def getUserHistory():
    # Get data from request
    data = request.get_json(silent=True)
    userID = str(data['userID'])
    buildingID = data['buildingID']
    token = data['token']

    if auth.checkToken(token):
        # Retrieve logs from database
        if (userID != 'None' and buildingID != 'None'):
            logs = db.retrieveLogs(userID=userID, building=buildingID)
        elif (userID != 'None' and buildingID == 'None'):
            logs = db.retrieveLogs(userID=userID)
        elif (userID == 'None' and buildingID != 'None'):
            logs = db.retrieveLogs(building=buildingID)
        elif (userID == 'None' and buildingID == 'None'):
            logs = db.retrieveLogs()
        return jsonify(logs)
    return '[S] Wrong access token'
コード例 #4
0
ファイル: server.py プロジェクト: RecruiterBill/zephyr-mobile
def assertAuthenticated(token):
    if not checkToken(token) or not checkTickets():
        raise AuthenticationRequired("Invalid token.")
コード例 #5
0
def getLoggedInUsers():
    data = request.get_json(silent=True)
    token = data['token']
    if auth.checkToken(token):
        return jsonify({"userID": db.getAllUsers()})
    return '[S] Wrong token'
コード例 #6
0
def assertAuthenticated(token):
    if not checkToken(token) or not checkTickets():
        raise AuthenticationRequired("Invalid token.")