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'
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'
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'
def assertAuthenticated(token): if not checkToken(token) or not checkTickets(): raise AuthenticationRequired("Invalid token.")
def getLoggedInUsers(): data = request.get_json(silent=True) token = data['token'] if auth.checkToken(token): return jsonify({"userID": db.getAllUsers()}) return '[S] Wrong token'